level-json-cache

Caching library with LevelDB backend

npm install level-json-cache
1 downloads in the last week
9 downloads in the last month

level-json-cache

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 (error, foo) {
    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

Install

$ npm install level-cache

Unlimited Caching

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

Manually Invalidating

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

Destroying

cache.destroy(function () {
  // done
});
npm loves you