I want to use Memoizee on my node.js backend, to speed up the requests.
But for some reason, I can't get it to work like I want to. I have a route, that waits for the callback of another method, but no matter how long I save the result in cache, it runs the whole method every time.
What am I doing wrong?
Here is an example of my implementation.
var memoize = require('memoizee');
module.exports = function (app) {
app.route('/someurl/:user_id')
.get(function (req, res) {
var user_id = req.params.user_id;
memoized(user_id, function (result) {
res.send(result)
})
});
};
var doWork = memoize(function(user_id, done) {
//Handling a lot of data - takes about 10-15 seconds
done(index);
});
var memoized = memoize(doWork, {maxAge: 300000});