Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarmicki committed May 22, 2015
1 parent 352cb4a commit fc64651
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
23 changes: 23 additions & 0 deletions test/cache-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

});

0 comments on commit fc64651

Please sign in to comment.