diff --git a/lib/cache.js b/lib/cache.js index e8b62fd..b5d5eba 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -11,9 +11,8 @@ function Cache(config) { var self = this; - this.clock = config.clock || Date; this.redisClient = config.redisClient || (function() { - var client = redis.createClient(config.port || 6379, config.host || 'localhost', config.options || {}); + var client = redis.createClient(config.port || 6379, config.host || '127.0.0.1', config.options || {}); if(config.auth) { client.auth(config.auth); } diff --git a/package.json b/package.json index 4e03568..dd69882 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "good-guy-cache-redis", - "version": "1.0.3", + "version": "1.0.4", "description": "Redis cache adapter for Good Guy HTTP", "main": "index.js", "scripts": { diff --git a/test/cache-test.js b/test/cache-test.js index 8b5b3c7..5abc84d 100644 --- a/test/cache-test.js +++ b/test/cache-test.js @@ -109,4 +109,27 @@ describe('Cache', function () { done(); }); + it('should create redis client with default options if it wasn\'t passed directly', function () { + + // given + var cache = new Cache(); + + // then + assert.equal(typeof cache.redisClient, 'object'); + assert.equal(cache.redisClient.address, '127.0.0.1:6379'); + }); + + it('should create redis client with custom options if they were specified', function () { + + // given + var cache = new Cache({ + host: '0.0.0.0', + port: '6969' + }); + + // then + assert.equal(typeof cache.redisClient, 'object'); + assert.equal(cache.redisClient.address, '0.0.0.0:6969'); + }); + });