express-redis-cache
express-redis-cache copied to clipboard
Prefix in cache.route not being set
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!
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.
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"
Got the same bug :( Going with the same workaround.