Expirable
Automatic expiring "cache" for Node.js. There must be tons of modules like these, but I couldn't find anyone that suites my needs. Just something simple but useful enought to transformed in to a module. Oh and the syntax is pretty as well <3
API
var Expirable = ; // all the keys you stuff in to the cache are saved for 5 minutes.var cache = '5 minutes'; // add a new item to the cache, expires in 5 minutes, as that is what we// configured above.cache; // add item to the cache, but for 10 minutes.cache; // get item from the cache, this will automatically update the internal last// used value, so it will be expired after 5 minutes, without any interactionvalue = cache; // same as above, except it will not touch the internal last used value and it// will expire 5 minutes after you have set itvalue = cache; // check if a value existscache ? 'yes' : 'no'; // remove a key from the cache.cache; // when a key is removed from the cache it will emit an event for it. This is// useful when you want to re-cache an item again when it expires.cache; // update the expiree of a keycache;cache; // alias for cache.remove, as it expired directly // stop the interal setinterval that scan for out of date keyscache; // start it again.cachestart; // kill everything, nuke that motherfucker.cache; // Oh! so you want to store the output of a Stream? sure!var stream = cache; // stream is the result of fs.createReadStream// once the stream fires it's `done` event, we will store the data. // iterate over the cachecache;
License
MIT