Stratocacher
A cache with pluggable layers.
Key features
Pluggable layers
Want to cache in memcached with a small in-memory LRU cache for hot values?
No problem! Stratocacher supports pluggable layers, and creating new layers is easy!
Automatic key generation
Stratocacher works on any function that:
- Is named (e.g.
function foo()
) - Takes only string and number arguments
- Returns a JSON-serializable value or a promise of a JSON-serializable value.
Background rebuild
Stratocacher supports separate time-to-live and time-to-rebuild.
If a request comes in between ttr
and ttl
then a background rebuild will
kick off and update the cache. No miss!
Usage
const getFoo = stratocacher;
wrap options
The wrap
function accepts a number of options.
stratocacher;
ttl
Time to live for cache values.
ttr
Time to rebuild for cache values.
layers
An array of layer classes. Layers are checked in order, earlier layers first.