express-bad-cache
Note: Real simple cache to be used on non production sites. Important! all the merit go to this project: https://github.com/jpresagios/express-api-cache
Cache a route Ready to use sample
var express = require("express");
var app = express();
var cacheService = require("express-bad-cache");
var cache = cacheService.cache;
app.get('/getPlayerList', cache('1 minutes', 'application/json'), (req, res) => {
// Do some work to retrieve movies and request before 10 minutes will get movies from cache
res.json([
{
"ServerKey": "TheIsland",
"ServerTag": "IS",
"PlayerName": "LeMorteine",
"CharacterName": "John Wick",
"TribeName": "Tribe of Lucaz"
},
{
"ServerKey": "TheIsland",
"ServerTag": "IS",
"PlayerName": "Luiss730",
"CharacterName": "xavi",
"TribeName": "Tribe of Lucaz"
}]);
});
app.listen(3000, function () {
console.log(`Example app listening on 3000!`);
});
API
-
valid units
- ms, second, minute, hour, day, week, month. -
duration format
- [time][unit] as5 minutes