cachecontrol.js
v1.0.7
Published
---------
Downloads
10
Readme
CacheControl.js
CacheControl is node module created to simplify the process of requesting / recieving / storing data in Redis Cache. The simple method takes in as parameters: the feed that should be request, the TTL for when the cache will expire and the key to store the data in.
Quick Example
var cc = require('cachecontrol');
cc.init('REDISSERVERURL', '6379', 'REDISPASSWORD');
cc.cache('http://www.mtv.com/', '60', 'MS:MTVHOME', function(feedData) {}, function(data) {});
cc.closeConnection();
Cache Function
The Cache Function function takes in the Feed URL, Cache Time (Seconds) and the Cache Key. It also takes in a callback function as well as a function to process the feed if there needs to be some normalization done prior to placing it in cache
cc.cache(FEED_URL, CACHE_TTL_SECS, CACHE_KEY,
processFeed(feedResponse) {
/** Process Feed Data Here **/
return result;
},
callback(result) {
/** Returns the Data from the Cache or the Feed Request **/
/** Return NULL Otherwise **/
}
);