Cache (library and service) implementation for nodejs.
$ npm install node-ciks
var ciks = require('../src/ciks').cache;
var mstorage = require('../src/memory-ciks/memory.js').storage;
var cache = new ciks();
var storage = new mstorage();
cache.storage(storage);
/// Now you can register cache producers, populate values and get cached ones.
For more use detailed cases please refer to example
Sets cache storage. Params:
Registers new data producer function. Params:
- alias — Producer function alias.
- producer — Callable producer function.
- ttlProducer — Callable function that produces cache TTL based on options passed to producer function.
Gets data from cache or populate it.
- alias — Producer function alias.
- options — Options to pass to producer function to populate data.
- promise — Promise to resolve when data is populated.
Populates new data and store it to cache.
- alias — Producer function alias.
- options — Options to pass to producer function to populate data.
- promise — Promise to resolve when data is populated.