fs-cash
v2.0.0
Published
A simple fs-persisted json cache.
Downloads
1
Readme
Quick start
npm install --save fs-cash
const cache = require('fs-cash');
cache.set('key', 'value').then(() => {
// saved
});
Everything is persisted to process.cwd()
/ .cash
cache.get('key').then((value) => {
// value = key
});
API
del( key:string ) :Promise
Delete cached value.
get( key:string ) :Promise<*>
Get cached value.
memoize( func:function [, serialize:function ] ) :function
Memoize a function.
const sqrt = cache.memoize(Math.sqrt);
sqrt(16).then((value) => { /* 4 */ });
set( key:string, value:* [, options:object] ) :Promise
Set cached value.
options.ttl :number
Cached value will expire after ttl
(time to live) milliseconds.
reset( key:string ) :Promise
Reset cache and delete cache file.