]> git.wh0rd.org Git - tt-rss.git/commitdiff
smart RPC I/O is now optional, add functionality to getLabelCounters()
authorAndrew Dolgov <fox@bah.spb.su>
Tue, 29 Nov 2005 13:55:53 +0000 (14:55 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Tue, 29 Nov 2005 13:55:53 +0000 (14:55 +0100)
backend.php
config.php-dist

index f79d7249e1edd7c62c6ca47ae860a8812d926f4b..0d59e7902e87b86f41974f1c1122bdbb7a344aaa 100644 (file)
@@ -73,7 +73,7 @@
                print "<counter id='global-unread' counter='$c_id'/>";
        }
 
-       function getTagCounters($link, $smart_mode = true) {
+       function getTagCounters($link, $smart_mode = SMART_RPC_COUNTERS) {
 
                if ($smart_mode) {
                        if (!$_SESSION["tctr_last_value"]) {
 
        }
 
-       function getLabelCounters($link) {
+       function getLabelCounters($link, $smart_mode = SMART_RPC_COUNTERS) {
+
+               if ($smart_mode) {
+                       if (!$_SESSION["lctr_last_value"]) {
+                               $_SESSION["lctr_last_value"] = array();
+                       }
+               }
+
+               $old_counters = $_SESSION["lctr_last_value"];
+               $lctrs_modified = false;
 
                $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries
                        WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND 
 
                        $count = db_fetch_result($tmp_result, 0, "count");
 
-                       print "<label id=\"$id\" counter=\"$count\"/>";
+                       if (!$smart_mode || $old_counters[$id] != $count) {     
+                               $old_counters[$id] = $count;
+                               $lctrs_modified = true;
+                               print "<label id=\"$id\" counter=\"$count\"/>";
+                       }
 
                        error_reporting (DEFAULT_ERROR_LEVEL);
-       
+               }
+
+               if ($smart_mode && $lctrs_modified) {
+                       $_SESSION["lctr_last_value"] = $old_counters;
                }
        }
 
                        print "<feed id=\"$id\" counter=\"$count\"/>";          
        }
 
-       function getFeedCounters($link, $smart_mode = true) {
+       function getFeedCounters($link, $smart_mode = SMART_RPC_COUNTERS) {
 
                if ($smart_mode) {
                        if (!$_SESSION["fctr_last_value"]) {
index 68c35ff44b036d0d8b924416c7ce54b86749f414..f24906c656708baf0eae9eff32170463f0b179c7 100644 (file)
@@ -38,4 +38,9 @@
        // */30 * * * * /usr/bin/wget -O /dev/null -T 600 "http://www.your-site.xxx/tt-rss/backend.php?op=globalUpdateFeeds&daemon=1"
        //
 
+       define('SMART_RPC_COUNTERS', true);
+       // If enabled, stores feed counter information on the server side and sends
+       // only diffs to the client. In the nutshell, it saves your bandwidth and
+       // makes UI more responsive, but eats server memory.    
+
 ?>