lazycache
lazy inmemory cache for node, automatic reset cache asynchronously when expired
Install
npm i lazycache --save
Usage
lazyCache()
Use the factory method to init a cache object:
var defaultCacheTime = 300000; // 300000 ms = 5 minvar cache = defaultCacheTime;
if defaultCacheTime < 0
, a noCache
object will return, which offer the same API but do NOT cache anything.
cache.get(key)
Get value from cache
- key: cache key
cache;
cache.set(key, val [, cacheTime] [, reseter])
Set value into cache
- key: cache key
- val: cache value
- cacheTime: cache time (ms)
- reseter: a function which reset the
cache value
var { // async ;};cache