0.0.7 • Published 10 years ago

arr-cache v0.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

arr-cache

Simple cache module for Node.js with interval based storage cleaning

Example

var cache = require('arr-cache');

// provide max interval after which
// items will be removed from storage
var c = cache({ keeptime: 3000 });  // default keeptime

// express middleware
exports.getProjects = function (req, res, next) {
  var key = req.session.id + '#projects';
  var projects = c.fetch(key);
  if ('undefined' !== typeof projects) {
    res.send({ projects: projects });
  } else {
    Project.find().exec(function (err, data) {
      if (err) return next(err);
      c.add(key, data, '5m');   // data will be stored in cache for 5 minutes
      res.send({ projects: data });
    });
  }
};

License

MIT

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago