cachelib-js

1.0.2 • Public • Published

JS Cache library that allows to store data and setup TTL.

Usage:

const { CacheService } = require('cachelib-js');

const cacheService = new CacheService;

// subscribe to service events (SET, GET, REMOVE)
cacheService.addListener(CacheService.events.SET, (event) => { /* response on SET event */ });

// set value to cache which will be non-actual after 10 sec
cacheService.set('key', { value: 'any value' }, { ttl: 10000 });

// get value
const result = cacheService.get('key');

// remove value
cacheService.remove('key');

// extract full data
const fullCacheData = cacheService.extract();

// preload data to service
cacheService.load(fullCacheData);

Readme

Keywords

Package Sidebar

Install

npm i cachelib-js

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

4.19 kB

Total Files

3

Last publish

Collaborators

  • thewillwillhelp