Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache always skipped when redis client created earlier is specified #115

Open
mjgs opened this issue Oct 7, 2018 · 0 comments
Open

Cache always skipped when redis client created earlier is specified #115

mjgs opened this issue Oct 7, 2018 · 0 comments

Comments

@mjgs
Copy link

mjgs commented Oct 7, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant