From: Andrew Dolgov Date: Mon, 19 May 2008 11:54:16 +0000 (+0100) Subject: getAllCounters: add rate limit (5 sec) X-Git-Tag: 1.2.23-final~45 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=d9e4bba015b7095673fe8d35315bff41bb1f6bcd;p=tt-rss.git getAllCounters: add rate limit (5 sec) --- diff --git a/functions.php b/functions.php index 87932e95..48caab06 100644 --- a/functions.php +++ b/functions.php @@ -2199,26 +2199,28 @@ } function getAllCounters($link, $omode = "flc", $active_feed = false) { -/* getLabelCounters($link); - getFeedCounters($link); - getTagCounters($link); - getGlobalCounters($link); - if (get_pref($link, 'ENABLE_FEED_CATS')) { - getCategoryCounters($link); - } */ - if (!$omode) $omode = "flc"; + /* getting all counters is a resource intensive operation, so we + * rate limit it a little bit */ - getGlobalCounters($link); + if (time() - $_SESSION["get_all_counters_stamp"] > 5) { - if (strchr($omode, "l")) getLabelCounters($link); - if (strchr($omode, "f")) getFeedCounters($link, SMART_RPC_COUNTERS, $active_feed); - if (strchr($omode, "t")) getTagCounters($link); - if (strchr($omode, "c")) { - if (get_pref($link, 'ENABLE_FEED_CATS')) { - getCategoryCounters($link); + if (!$omode) $omode = "flc"; + + getGlobalCounters($link); + + if (strchr($omode, "l")) getLabelCounters($link); + if (strchr($omode, "f")) getFeedCounters($link, SMART_RPC_COUNTERS, $active_feed); + if (strchr($omode, "t")) getTagCounters($link); + if (strchr($omode, "c")) { + if (get_pref($link, 'ENABLE_FEED_CATS')) { + getCategoryCounters($link); + } } + + $_SESSION["get_all_counters_stamp"] = time(); } + } function getCategoryCounters($link) {