node-chaching

0.2.0 • Public • Published

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

Package Sidebar

Install

npm i node-chaching

Weekly Downloads

0

Version

0.2.0

License

Apache-2.0

Unpacked Size

7.34 kB

Total Files

5

Last publish

Collaborators

  • tbrzz05