]> git.wh0rd.org - tt-rss.git/blobdiff - update_daemon.php
query optimizations; split big feed update transaction
[tt-rss.git] / update_daemon.php
index da94050fc31ea7f23b064ee0d94ef64e009b7cf2..cf51bdd3abfe090ff28a76e438bffd7bc458fa37 100644 (file)
                $result = db_query($link, "SELECT feed_url,id,owner_uid,
                        SUBSTRING(last_updated,1,19) AS last_updated,
                        update_interval FROM ttrss_feeds ORDER BY last_updated DESC");
-       
+
+               $user_prefs_cache = array();
+
                while ($line = db_fetch_assoc($result)) {
        
                        $upd_intl = $line["update_interval"];
                        $user_id = $line["owner_uid"];
        
                        if (!$upd_intl || $upd_intl == 0) {
-                               $upd_intl = get_pref($link, 'DEFAULT_UPDATE_INTERVAL', $user_id);
+                               if (!$user_prefs_cache[$user_id]['DEFAULT_UPDATE_INTERVAL']) {                  
+                                       $upd_intl = get_pref($link, 'DEFAULT_UPDATE_INTERVAL', $user_id);
+                                       $user_prefs_cache[$user_id]['DEFAULT_UPDATE_INTERVAL'] = $upd_intl;
+                               } else {
+                                       $upd_intl = $user_prefs_cache[$user_id]['DEFAULT_UPDATE_INTERVAL'];
+                               }
                        }
 
                        if ($upd_intl < 0) { 
        
                                print "Updating...\n";  
                                update_rss_feed($link, $line["feed_url"], $line["id"], true);   
-                               sleep(3); // prevent flood (FIXME make this an option?)
+                               sleep(1); // prevent flood (FIXME make this an option?)
                        } else {
                                print "Update not needed.\n";
                        }