carbon-cache
carbon-cache
Is a simple, light weight and extendable in memory cache.
Install
$ npm install --save carbon-cache
Example
// Using good old requireconst CarbonCache = ; // Using import; const myCache = 100; // Create myCache valid for 100 seconds i.e. TTL is 100 seconds.const myCache = ; // TTL is completly optional. This is perfectly valid. // Populate Cache with JSON datamyCache; // Put an item into the CachemyCache; // Check if a key exist in CachemyCache; // Get an item from the CachemyCache; // Delete an item from the CachemyCache; // Export complete contents of Cache as JSONmyCache; // Flush complete contents of CachemyCache; // Check if the cache is emptymyCache;
The TTL is for complete Cache and validity of the complete cache is extended by the TTL provided while creating the Cache when a new item is added to the Cache. If no TTL specified while creating Cache, it lives on as long as the node process is alive.