summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/quotesgrab/quotesgrab.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/quotesgrab/quotesgrab.js b/modules/quotesgrab/quotesgrab.js
index 37f44e6..c540d3a 100644
--- a/modules/quotesgrab/quotesgrab.js
+++ b/modules/quotesgrab/quotesgrab.js
@@ -57,11 +57,19 @@ function getquoteslist(cb){
});
}
+var cache=null,cachedate=null;
+
module.exports=function(app,io,moddir){
app.get("/quotes",function(req,res){
res.set("Content-Type", "text/json");
- getquoteslist(function(obj){
- res.end(JSON.stringify(obj));
- });
+ if(cache!=null&&new Date()-cachedate<60*1000){
+ res.end(cache);
+ } else {
+ getquoteslist(function(obj){
+ cache=JSON.stringify(obj);
+ cachedate=new Date();
+ res.end(cache);
+ });
+ }
});
};