Simple cache config handling for your app or module
If you don't need caching, you should use conf instead. This module extends that module and abstracts away the caching mechanism.
$ npm install --save cache-conf
const delay = require('delay');
const CacheConf = require('cache-conf');
const config = new CacheConf();
config.set('unicorn', '🦄', {maxAge: 5000});
console.log(config.get('unicorn'));
//=> '🦄'
// Wait 5 seconds
await delay(5000);
console.log(config.get('unicorn'));
//=> undefined
Returns a new instance.
Any of the conf options.
An extended conf instance.
Get an item.
Type: boolean
Default: false
Get the item for the key
provided without taking the maxAge
of the item into account.
Set an item.
Set multiple items at once.
Type: number
Number of milliseconds the cached value is valid.
Type: string
Version number of the data. If the version provided is not the same as the version of the cached data, the data will be invalid.
Boolean indicating if the cached data is expired.
- conf - Simple config handling for your app or module
- observable-conf - Listen for changes in your conf config
MIT © Sam Verschueren