]> git.wh0rd.org Git - tt-rss.git/commitdiff
enable cache of feedlist data
authorAndrew Dolgov <fox@bah.org.ru>
Mon, 2 Feb 2009 12:14:34 +0000 (15:14 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Mon, 2 Feb 2009 12:14:34 +0000 (15:14 +0300)
feedlist.js
tt-rss.js
viewfeed.js

index 8f1b5efec2cf5e2e126c6f224b612c32423f56e8..e148337c7b58cbbe16c69bb626f6324055a558a1 100644 (file)
@@ -30,13 +30,25 @@ function viewCategory(cat) {
        return false;
 }
 
+function render_feedlist(data) {
+       try {
+
+               var f = document.getElementById("feeds-frame");
+               f.innerHTML = data;
+               cache_invalidate("FEEDLIST");
+               cache_inject("FEEDLIST", data);
+               feedlist_init();
+
+       } catch (e) {
+               exception_error("render_feedlist", e);
+       }
+}
+
 function feedlist_callback2(transport) {
        try {
                debug("feedlist_callback2");
                if (!transport_error_check(transport)) return;
-               var f = document.getElementById("feeds-frame");
-               f.innerHTML = transport.responseText;
-               feedlist_init();
+               render_feedlist(transport.responseText);
        } catch (e) {
                exception_error("feedlist_callback2", e);
        }
@@ -257,6 +269,7 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
                        f.innerHTML = cache_find_param(cache_prefix + feed, unread_ctr);
 
                        request_counters();
+                       remove_splash();
 
                } else {
 
index d49eaa6be472c9d9dacd5023593c215131f74d21..c3c21cc20cf1140041fd5b6caee83a4f4ce7091e 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -510,7 +510,14 @@ function init_second_stage() {
                daemon_refresh_only = getInitParam("daemon_refresh_only") == 1;
                feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
 
-               setTimeout('updateFeedList(false, false)', 50);
+               var fl = cache_find("FEEDLIST");
+
+               if (fl) {
+                       render_feedlist(fl);
+                       request_counters();
+               } else {
+                       setTimeout('updateFeedList(false, false)', 50);
+               }
 
                debug("second stage ok");
 
@@ -1472,6 +1479,8 @@ function init_gears() {
 
                        db.execute("CREATE TABLE IF NOT EXISTS cache (id text, article text, param text, added text)");
                }       
+       
+               cache_expire();
 
        } catch (e) {
                exception_error("init_gears", e);
index 615f366f3dca04edb716a07363b8f5654e384c45..6f018d19ca2e079206047ef3f0033eab83d7e697 100644 (file)
@@ -1500,6 +1500,11 @@ function cache_inject(id, article, param) {
 function cache_find(id) {
 
        if (db) {
+               var rs = db.execute("SELECT article FROM cache WHERE id = ?", [id]);
+
+               if (rs.isValidRow()) {
+                       return rs.field(0);
+               }
 
        } else {
                for (var i = 0; i < article_cache.length; i++) {
@@ -1572,7 +1577,13 @@ function cache_check_param(id, param) {
 }
 
 function cache_expire() {
-       if (!db) {
+       if (db) {
+               var date = new Date();
+               var ts = Math.round(date.getTime() / 1000);
+
+               db.execute("DELETE FROM cache WHERE added < ? - 600", [ts]);
+
+       } else {
                while (article_cache.length > 25) {
                        article_cache.shift();
                }