From cfc4d59ee719eb5c6e43e5f6fbf4b815865a904a Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 9 Jul 2017 23:15:14 +0200 Subject: [PATCH] api: memcache status for 30 second --- web/yaamp/modules/api/ApiController.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/web/yaamp/modules/api/ApiController.php b/web/yaamp/modules/api/ApiController.php index ea96c3a..fc94197 100644 --- a/web/yaamp/modules/api/ApiController.php +++ b/web/yaamp/modules/api/ApiController.php @@ -10,7 +10,15 @@ class ApiController extends CommonController public function actionStatus() { - if(!LimitRequest('api-status', 10)) return; + //if(!LimitRequest('api-status', 10)) return; + + $memcache = controller()->memcache->memcache; + $json = memcache_get($memcache, "api_status"); + + if (!empty($json)) { + echo $json; + return; + } $stats = array(); foreach(yaamp_get_algos() as $i=>$algo) @@ -77,7 +85,11 @@ class ApiController extends CommonController } ksort($stats); - echo json_encode($stats); + + $json = json_encode($stats); + echo $json; + + memcache_set($memcache, "api_status", $json, MEMCACHE_COMPRESSED, 30); } public function actionCurrencies()