Clean Cache
Simple single-file, in-memory javascript cache fully tested and without any dependencies.
Initially part of statg.
Install
npm install clean-cache
Use
const Cache = ; const myCache = 30000; // ttl in ms, if omitted defaults to 60s // adding itemsmyCache; // adds object under key '1' for 30smyCache; // expires in 1s instead of 30smyCache; // throws errormyCache; // throws error // retrieving itemsmyCache; // returns { foo: 'bar' }myCache; // returns nullmyCache; // throws errormyCache; // throws error // othermyCache; // returns number of objects in cachemyCache; // removes all expired items from cache
License
MIT