level-json-cache

Caching library with LevelDB backend

Caching library with LevelDB backend and english-time enabled interface.

cache = require('level-json-cache')('foobar')
 
cache.set('foo', { span: 'eggs', 'bar': 314 }, '5 days', function (error) {
  if (error) throw error;
 
  cache.get('foo', function (errorfoo) {
    if (error) throw error;
 
    console.log('foo in cache:', foo)
  })
})

Example Time Inputs:

  • 1000
  • 1 week 3 days
  • 1 hour, 5 minutes and 15 seconds

Full Reference: english-time

$ npm install level-cache

Pass -1 or 'never' to not define any expiration.

cache.invalidate('whatever', function (){
  // done 
});
cache.destroy(function () {
  // done 
});