tiny-ttl-cache
v1.0.1
Published
Simple TTL cache. put and get.
Downloads
3
Readme
Simple TTL cache. put and get.
Suitable for use in browsers and Node.js.
Install
$ npm install --save tiny-ttl-cache
Usage
var TTLCache = require('tiny-ttl-cache');
var maxSize = 100;
var timeToLive = 10 * 1000; // 10s in ms
var cache = new TTLCache(maxSize, timeToLive);
cache.put('key', 'value');
cache.get('key'); // returns 'value'
// 10 seconds later
cache.get('key'); // returns null
cache.flush(); // Empties the cache
TTL Eviction Policy
Once the cache reaches its maximum size, the item with the shortest TTL is removed.
Development
npm install
npm test
License
MIT © Andy Hume