node-json-cache
Use a json file as a cache.
Usage
; cache = ;// set an itemcache; // 'value'// get an itemcache; // 'value'// gets entire cachecache; // { key: 'value' }// overwrite cachecache; // { hello: 'world' }// synchronously saves the cachecache;// clears the cachecacheclear;
Options
const cache = ;
filename
- path to cache fileoptions
- optionaloptions
.out
- optional, output operations to console, defaults tofalse
options
.wait
- optional, debounce time on operations, defaults to1000
options
.ejectable
- optional, save on exit/error, defaults tofalse
filesystem perfomance
Storage operations are batched. Storage is persisted on exit.
See also
Inspired by [Node LocalCache(https://github.com/glebmachine/node-localcache), With notable changes:
- explicity operate with a file, no
skipFileCachig
- allow setting of
undefined
as a value - allow getting and setting of the entire file
- async file saving by default
- more settings