Skip to content

Commit

Permalink
Making it more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-seville committed Apr 10, 2013
1 parent ccb6050 commit 486161c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions index.js
@@ -1,20 +1,20 @@
var cache={};

module.exports = {
checkCache: function(key,cb){
checkCache: function(key){
if (cache[key]){
if (new Date().getTime() < cache[key].expires){
console.log("using cache, expires on ",cache[key].expires);
cb(cache[key].html);
return true;
//console.log("using cache, expires on ",cache[key].expires);
return cache[key].value;
}else{
console.log("removing cache");
//console.log("cache expired, removing cache");
delete cache[key];
}
}
return null;
},
add: function(key,value,expiryDate){
cache[key]={html: value,expires: expiryDate || new Date().setHours(new Date().getHours()+1)};
//defaults to a one hour expiry
cache[key]={value: value,expires: expiryDate || new Date().setHours(new Date().getHours()+1)};
}
};

0 comments on commit 486161c

Please sign in to comment.