From 72cc6f1570a2a829933688142ba3a2f607b13f44 Mon Sep 17 00:00:00 2001
From: tomsmeding <tom.smeding@gmail.com>
Date: Tue, 4 Apr 2017 23:03:39 +0200
Subject: quotesgrab: cache results briefly

---
 modules/quotesgrab/quotesgrab.js | 14 +++++++++++---
 1 file 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);
+			});
+		}
 	});
 };
-- 
cgit v1.2.3-70-g09d2