The Filesystem store for the node-cache-manager module, storing binary data as separate files, returning them as readable streams or buffers.
This should be convenient for caching binary data and sending them as streams to a consumer, e.g.
The library caches on disk arbitrary data, but values of an object under the special key
binary is stored as separate files.
Works with versions 4, 5 and iojs.
npm install cache-manager-fs-binary --save
Here are examples that demonstrate how to implement the Filesystem cache store.
// node cachemanagervar cacheManager = ;// storage for the cachemanagervar fsStore = ;// initialize caching on diskvar diskCache = cacheManager;// ...var cacheKey = 'userImageWatermarked:' + userid + ':' + imageid;var ttl = 60 * 60 * 24 * 7; // in seconds// wrapper function, see more examples at node-cache-managerdiskCache
options for store initialization
// default values// time to live in secondsoptionsttl = 60;// path for cached filesoptionspath = 'cache/';// prevent filling of the cache with the files from the cache-directoryoptionspreventfill = false;// callback fired after the initial cache filling is completedoptionsfillcallback = null;// if true the main cache files will be zipped (not the binary ones)optionszip = false;// if true buffers not from binary key are returned from cache as buffers,// not objectsoptionsreviveBuffers = false;// if true, data in the binary key are returned as StreamReadable and// (**NB!**) the source object will also be changed.// You have to do the work for closing the files if you do not read them,// see example.optionsbinaryAsStream = false;
To run tests:
To run Coverage:
npm run coverage
cache-manager-fs-binary is licensed under the MIT license.