catbox-redis
Advanced tools
Comparing version 2.0.2 to 3.0.0
@@ -1,1 +0,1 @@ | ||
Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md). | ||
Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/.github/CONTRIBUTING.md). |
@@ -6,3 +6,3 @@ | ||
const Redis = require('redis'); | ||
const Redis = require('ioredis'); | ||
const Hoek = require('hoek'); | ||
@@ -26,3 +26,3 @@ | ||
this.settings = Hoek.applyToDefaults(internals.defaults, options); | ||
this.settings = Object.assign({}, internals.defaults, options); | ||
this.client = options.client || null; | ||
@@ -44,17 +44,14 @@ return this; | ||
const options = { | ||
password: this.settings.password, | ||
db: this.settings.database || this.settings.db | ||
}; | ||
if (this.settings.socket) { | ||
client = Redis.createClient(this.settings.socket); | ||
client = Redis.createClient(this.settings.socket, options); | ||
} | ||
else { | ||
client = Redis.createClient(this.settings.port, this.settings.host); | ||
client = Redis.createClient(this.settings.port, this.settings.host, options); | ||
} | ||
if (this.settings.password) { | ||
client.auth(this.settings.password); | ||
} | ||
if (this.settings.database) { | ||
client.select(this.settings.database); | ||
} | ||
// Listen to errors | ||
@@ -92,3 +89,3 @@ | ||
return !!this.client && this.client.connected; | ||
return !!this.client; | ||
}; | ||
@@ -159,3 +156,3 @@ | ||
stored: Date.now(), | ||
ttl: ttl | ||
ttl | ||
}; | ||
@@ -162,0 +159,0 @@ |
{ | ||
"name": "catbox-redis", | ||
"description": "Redis adapter for catbox", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -20,9 +20,9 @@ "contributors": [ | ||
"dependencies": { | ||
"redis": "2.x.x", | ||
"hoek": "4.x.x" | ||
"hoek": "4.x.x", | ||
"ioredis": "2.x.x" | ||
}, | ||
"devDependencies": { | ||
"catbox": "7.x.x", | ||
"code": "2.x.x", | ||
"lab": "10.x.x" | ||
"code": "4.x.x", | ||
"lab": "13.x.x" | ||
}, | ||
@@ -29,0 +29,0 @@ "scripts": { |
@@ -10,3 +10,3 @@ | ||
const Redis = require('..'); | ||
const RedisClient = require('redis'); | ||
const RedisClient = require('ioredis'); | ||
@@ -96,3 +96,3 @@ | ||
it('gets an item after settig it', (done) => { | ||
it('gets an item after setting it', (done) => { | ||
@@ -496,10 +496,7 @@ const client = new Catbox.Client(Redis); | ||
redis.start(() => {}); | ||
redis.start(() => { | ||
// redis.client.selected_db gets updated after the callback | ||
setTimeout(() => { | ||
done(); | ||
expect(redis.client.selected_db).to.equal(1); | ||
done(); | ||
}, 10); | ||
}); | ||
}); | ||
@@ -520,4 +517,2 @@ | ||
expect(client).to.exist(); | ||
expect(client.connected).to.equal(true); | ||
expect(client.address).to.equal(options.socket); | ||
done(); | ||
@@ -591,25 +586,2 @@ }); | ||
}); | ||
it('returns false when disconnected', (done) => { | ||
const options = { | ||
host: '127.0.0.1', | ||
port: 6379 | ||
}; | ||
const redis = new Redis(options); | ||
redis.start((err) => { | ||
expect(err).to.not.exist(); | ||
expect(redis.client).to.exist(); | ||
expect(redis.isReady()).to.equal(true); | ||
redis.client.end(); | ||
expect(redis.isReady()).to.equal(false); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -616,0 +588,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34034
873
+ Addedioredis@2.x.x
+ Addedbluebird@3.7.2(transitive)
+ Addedcluster-key-slot@1.1.2(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedflexbuffer@0.0.6(transitive)
+ Addedioredis@2.5.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedms@2.0.0(transitive)
+ Addedredis-parser@1.3.0(transitive)
- Removedredis@2.x.x
- Removedredis@2.8.0(transitive)
- Removedredis-parser@2.6.0(transitive)