The key-value storage with TTL (time to live) support, allowing you to add, modify or delete stored data items.
$ npm install cache-ttl
JavaScript:
const cache = require('cache-ttl').Cache;
// OR const cache = require('cache-ttl').default;
// OR const { Cache } = require('cache-ttl');
cache.set('foo', 'bar');
console.log(cache.get('foo'));
TypeScript:
import Cache from 'cache-ttl';
// OR import { Cache } from 'cache-ttl';
Cache.set('foo', 'bar');
console.log(Cache.get<string>('foo'));
Cache.set('foo', 'bar', 10); // Will expire after 10 seconds
Cache.count(); // Count items
Cache.remove('foo'); // Remove item by key
Cache.clear(); // Flush cache