cachecontrol.js

1.0.7 • Public • Published

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.js');

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 **/
  }
);

Readme

Keywords

none

Package Sidebar

Install

npm i cachecontrol.js

Weekly Downloads

0

Version

1.0.7

License

none

Last publish

Collaborators

  • raman148
  • mbuff24