cacheman-level
Standalone caching library for Node.JS and also cache engine for cacheman using LevelDB specifically level.
Instalation
$ npm install cacheman-level
Usage
Promise is support
const CachemanLevel = ;const cache = './DS_Store'; //location;async { // set the value await cache; const value = await cache; console; //-> {foo:"bar"} }
const CachemanLevel = ;const cache = './DS_Store'; //location // set the valuecache;
API
CachemanLevel(location, [options, error-handler])
Create cacheman-level
instance. options
are level options including checkFrequency
.
const options = prefix: 'cache' checkFrequency: 15 * 1000; const cache = location options;
more options get be found here
cache.set(key, value, [ttl, [fn]])
Stores or updates a value.
cache;
Or add a TTL(Time To Live) in seconds like this:
// key will expire in 60 secondscache;
cache.get(key, fn)
Retrieves a value for a given key, if there is no value for the given key a null value will be returned.
cache;
cache.del(key, [fn])
Deletes a key out of the cache.
cache;
cache.clear([fn])
Clear the cache entirely, throwing away all values.
cacheclear { if err throw err; // cache is now clear};
Run tests
$ npm test