]> git.wh0rd.org Git - tt-rss.git/commitdiff
getAllCounters: add rate limit (5 sec)
authorAndrew Dolgov <fox@bah.spb.su>
Mon, 19 May 2008 11:54:16 +0000 (12:54 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Mon, 19 May 2008 11:54:16 +0000 (12:54 +0100)
functions.php

index 87932e95456c699ab0df2e1898713bb29812c147..48caab0613559c4747673b5c2059505c6771545e 100644 (file)
        }
 
        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) {