Cache always skipped when redis client created earlier is specified
Opened this issue · 0 comments
mjgs commented
When I pass a redis client I created earlier as an option the cache is always skipped.
Looking into the code the cache is always skipped when this.connected === false:
// ExpressRedisCache.js:
if ( self.connected === false || self.client.connected === false ) {
return next();
}
This is actually the default value, which gets updated when the 'connect' event happens:
// ExpressRedisCache/route.js:
this.client.on('connect', function () {
this.connected = true;
this.emit('connected', { host: this.host, port: this.port });
this.emit('message', 'OK connected to redis://' + this.client.address);
}.bind(this));
But since the 'connect' event happened earlier, this.connected never gets set correctly and so the cache is always skipped.
I have tested pull-request #96 in a fork and it fixes the issue, it would be great to have it merged in.