A simple in-memory cache for Node.js
npm install @aprodan/cache
const cache = require('@aprodan/cache');
cache.put('key', 'value');
const val = cache.get('key')
console.log('val=', val); // => val='value'
- Retrieves a value for a given key
- If there is not existing an record for the given key, there will be returned null.
- Stores a value in the cache
- If time is passed, then it will be stored temporarly for that given amount of time (seconds)
- An optional timeout callback function could be provided, that will run after the entry has expired
- Returns keys that are stored in cache.
- Removes the record stored at the given key.
- Removes all the records stored in the cache, and resets it.
- Returns current number of records stored in the cache.
- Returns total number of cache hits.
- Returns total number of cache misses.
- Returns a JSON string representing all the cache data.