summaryrefslogtreecommitdiff
path: root/viewfeed.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2009-02-02 15:14:34 +0300
committerAndrew Dolgov <[email protected]>2009-02-02 15:14:34 +0300
commit31234407bffa5debe79250e93a4168ea2251e094 (patch)
treecec9e513cc54632d7d609a92f61996641c0afff3 /viewfeed.js
parentfb456d28f227f4bd903c7ec736425ba64a5700f3 (diff)
enable cache of feedlist data
Diffstat (limited to 'viewfeed.js')
-rw-r--r--viewfeed.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/viewfeed.js b/viewfeed.js
index 615f366f3..6f018d19c 100644
--- a/viewfeed.js
+++ b/viewfeed.js
@@ -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();
}