express-bad-cache

1.0.0 • Public • Published

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] as 5 minutes

Package Sidebar

Install

npm i express-bad-cache

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

4.17 kB

Total Files

5

Last publish

Collaborators

  • rlyehdoom