enable cache of feedlist data
This commit is contained in:
parent
fb456d28f2
commit
31234407bf
19
feedlist.js
19
feedlist.js
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
var fl = cache_find("FEEDLIST");
|
||||
|
||||
if (fl) {
|
||||
render_feedlist(fl);
|
||||
request_counters();
|
||||
} else {
|
||||
setTimeout('updateFeedList(false, false)', 50);
|
||||
}
|
||||
|
||||
debug("second stage ok");
|
||||
|
||||
|
@ -1473,6 +1480,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);
|
||||
}
|
||||
|
|
13
viewfeed.js
13
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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue