Skip to content

tbrzz01/node-chaching

Repository files navigation

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

About

A reusable node caching class

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published