A node in-memory cache helper that serves an object from cache as long as it requested within the specified time frame.
var SlidingCache = require('sliding-cache');
var slidingCache = new SlidingCache();
var liveDataSource = function(callback) {
httprequestmodule.get(url, data, function(err, response) {
if(!err) {
callback(response.body);
}
});
}
slidingCache.Run('SOME_KEY_HERE', liveDataSource, function(data) {
res.json(data);
}, 7000);