]> git.wh0rd.org Git - tt-rss.git/commitdiff
update prefetching store, add expiry
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 15 May 2007 05:21:19 +0000 (06:21 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 15 May 2007 05:21:19 +0000 (06:21 +0100)
functions.js
viewfeed.js

index 09f430096830e88e5433c900d318eec0ccac0db0..0677308f42100773adec9fdc51ec246d74d436d1 100644 (file)
@@ -1687,9 +1687,9 @@ function getRelativePostIds(id) {
                                if (i > 1) ids.push(rows[i-2].id.replace("RROW-", ""));
                                if (i > 2) ids.push(rows[i-3].id.replace("RROW-", ""));
 
-                               if (i < rows.length) ids.push(rows[i+1].id.replace("RROW-", ""));
-                               if (i < rows.length-1) ids.push(rows[i+2].id.replace("RROW-", ""));
-                               if (i < rows.length-2) ids.push(rows[i+3].id.replace("RROW-", ""));
+                               if (i < rows.length-1) ids.push(rows[i+1].id.replace("RROW-", ""));
+                               if (i < rows.length-2) ids.push(rows[i+2].id.replace("RROW-", ""));
+                               if (i < rows.length-3) ids.push(rows[i+3].id.replace("RROW-", ""));
 
                                return ids;
                        }
index f5791eaf7f21ed7e9f0f998618eb959a3ceb57ad..4cba45ef8d3cbb7b28419dda60cd78652a417e8e 100644 (file)
@@ -738,16 +738,21 @@ function cdmWatchdog() {
 
 
 function cache_inject(id, article) {
-       if (!article_cache[id]) {
+       if (!cache_check(id)) {
                debug("cache_article: miss: " + id);
 
                var cache_obj = new Array();
 
                var d = new Date();
+
+               cache_obj["id"] = id;
                cache_obj["entered"] = d.getTime() / 1000;
                cache_obj["data"] = article;
+               cache_obj["last_access"] = 0;
+
+               //article_cache[id] = cache_obj;
 
-               article_cache[id] = cache_obj;
+               article_cache.push(cache_obj);
 
        } else {
                debug("cache_article: hit: " + id);
@@ -755,17 +760,27 @@ function cache_inject(id, article) {
 }
 
 function cache_find(id) {
-       if (typeof article_cache[id] != 'undefined') {
-               return article_cache[id]["data"];
-       } else {
-               return false;
+       for (var i = 0; i < article_cache.length; i++) {
+               if (article_cache[i]["id"] == id) {
+                       var d = new Date();
+                       article_cache[i]["last_access"] = d.getTime() / 1000;
+                       return article_cache[i]["data"];
+               }
        }
+       return false;
 }
 
 function cache_check(id) {
-       return typeof article_cache[id] != 'undefined';
+       for (var i = 0; i < article_cache.length; i++) {
+               if (article_cache[i]["id"] == id) {
+                       return true;
+               }
+       }
+       return false;
 }
 
 function cache_expire() {
-       /* TODO */
+       while (article_cache.length > 30) {
+               article_cache.shift();
+       }
 }