catbox-redis
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -47,3 +47,8 @@ | ||
if (this.settings.url) { | ||
if (this.settings.sentinels && this.settings.sentinels.length) { | ||
options.sentinels = this.settings.sentinels; | ||
options.name = this.settings.sentinelName; | ||
client = Redis.createClient(options); | ||
} | ||
else if (this.settings.url) { | ||
client = Redis.createClient(this.settings.url, options); | ||
@@ -50,0 +55,0 @@ } |
{ | ||
"name": "catbox-redis", | ||
"description": "Redis adapter for catbox", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -17,2 +17,4 @@ catbox-redis [![Build Status](https://travis-ci.org/hapijs/catbox-redis.svg?branch=master)](https://travis-ci.org/hapijs/catbox-redis) | ||
- `partition` - this will store items under keys that start with this value. (Default: '') | ||
- `sentinels` - an array of redis sentinel addresses to connect to. | ||
- `sentinelName` - the name of the sentinel master. (Only needed when `sentinels` is specified) | ||
@@ -19,0 +21,0 @@ ## Tests |
@@ -11,2 +11,3 @@ | ||
const RedisClient = require('ioredis'); | ||
const EventEmitter = require('events').EventEmitter; | ||
@@ -25,2 +26,4 @@ | ||
const it = lab.test; | ||
const before = lab.before; | ||
const after = lab.after; | ||
@@ -537,2 +540,57 @@ | ||
describe('', () => { | ||
const oldCreateClient = RedisClient.createClient; | ||
before((done) => { | ||
RedisClient.createClient = function (opts) { | ||
const out = new EventEmitter(); | ||
process.nextTick(() => { | ||
out.emit('ready'); | ||
out.removeAllListeners(); | ||
}); | ||
out.callArgs = opts; | ||
return out; | ||
}; | ||
done(); | ||
}); | ||
after((done) => { | ||
RedisClient.createClient = oldCreateClient; | ||
done(); | ||
}); | ||
it('connects to a sentinel cluster.', (done) => { | ||
const options = { | ||
sentinels: [ | ||
{ | ||
host: '127.0.0.1', | ||
port: 26379 | ||
}, | ||
{ | ||
host: '127.0.0.2', | ||
port: 26379 | ||
} | ||
], | ||
sentinelName: 'mymaster' | ||
}; | ||
const redis = new Redis(options); | ||
redis.start((err) => { | ||
expect(err).to.not.exist(); | ||
const client = redis.client; | ||
expect(client).to.exist(); | ||
expect(client.callArgs.sentinels).to.equal(options.sentinels); | ||
expect(client.callArgs.name).to.equal(options.sentinelName); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('does not stops the client on error post connection', (done) => { | ||
@@ -539,0 +597,0 @@ |
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
36807
939
33