Skip to content

Commit

Permalink
address connection issue #92
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuspoehls committed Oct 9, 2018
1 parent 3571b07 commit adfe8e0
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lib/index.js
Expand Up @@ -15,9 +15,12 @@ exports = module.exports = class Connection {
Hoek.assert(this instanceof Connection, 'Redis cache client must be instantiated using new');

this.client = null;
this.settings = Object.assign({}, defaults, options);

return this;
this.settings = Object.assign({}, defaults, options, {
db: options.database || options.db,
name: options.sentinelName,
tls: options.tls,
lazyConnect: true
});
}

async start() {
Expand All @@ -30,14 +33,17 @@ exports = module.exports = class Connection {
return;
}

const options = Object.assign({}, this.settings, {
db: this.settings.database || this.settings.db,
name: this.settings.sentinelName,
tls: this.settings.tls,
lazyConnect: true
});
let client;

const client = new Redis(options);
if (this.settings.url) {
client = new Redis(this.settings.url, this.settings);
}
else if (this.settings.socket) {
client = new Redis(this.settings.socket, this.settings);
}
else {
client = new Redis(this.settings);
}

client.on('error', () => {

Expand Down

0 comments on commit adfe8e0

Please sign in to comment.