0.2.0 • Published 5 years ago

node-chaching v0.2.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
5 years ago

node-chaching NPM version Build Status Dependency Status Coverage percentage

Reusable single-purpose caching class for node

Installation

$ npm install --save node-chaching

Usage

const Cache = require('node-chaching');

// create a new Cache instance with a 10 sec TTL and a get Promise
// that provides values when a cache miss occurs
const myCache = new Cache(10, (key) => Promise.resolve({key, value: 10}));

const args = {
  key: 'key-1',
  options: {
    opt1: [],
    opt2: 'opt2'
  }
};
// retrieve value for given key
const value = await myCache.get(args);

// delete key and its value from cache
myCache.del('key-1');

License

Apache-2.0 © Trey Briggs