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

Prefix in cache.route not being set #79

Open
valedaemon opened this issue Nov 28, 2016 · 3 comments
Open

Prefix in cache.route not being set #79

valedaemon opened this issue Nov 28, 2016 · 3 comments

Comments

@valedaemon
Copy link

Our app needs the ability to set a dynamic cache prefix. However, whenever I call cache.route({prefix: 'blah'}) and check what prefix is being utilized, it's always 'erc:'. How can I get cache.route to correctly set a prefix?

Thanks!

@valedaemon
Copy link
Author

I solved the issue by dynamically setting the name instead of a prefix. The fact that it doesn't seem possible to define the prefix from cache.route() appears to still be a bug, though.

@mjgs
Copy link

mjgs commented Oct 5, 2018

I got this working using this code:

var http = require('http');
var express = require('express');
var cache = require('express-redis-cache');

var app = express();
var cache = cache({
  prefix: 'test-prefix'
});

app.get('/test', cache.route(), function (req, res) {
  console.log('inside the test route');
  return res.status(200).json({ result: 'done' });
});

http.createServer(app).listen(8080, 'localhost', function(err) {
  if (err) { throw err; }
  console.log('Web server listening at http://localhost:8080');
});

Loading http://localhost:8080/test results in the db entry:

127.0.0.1:6379> keys *
1) "test-prefix:/test"

@iplanwebsites
Copy link

Got the same bug :(
Going with the same workaround.

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

No branches or pull requests

4 participants