Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccb6050
commit 486161c
Showing
1 changed file
with
6 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)}; | ||
} | ||
}; |