ssb: Get saving the about cache off of the main load path.

This commit is contained in:
Cory McWilliams 2024-12-24 12:05:31 -05:00
parent 41e91f2922
commit 68f6c90ea4
2 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,5 @@
{ {
"type": "tildefriends-app", "type": "tildefriends-app",
"emoji": "🦀", "emoji": "🦀",
"previous": "&PP5y+K7wgLxdkeeb4iqyK1Fb+vwS9LjLJDt2FPrVlpo=.sha256" "previous": "&e997wZKsisgdoMKDf52LAk4Vzzdhbp9M25eC68AoReE=.sha256"
} }

View File

@ -148,6 +148,7 @@ class TfElement extends LitElement {
async fetch_about(ids, users) { async fetch_about(ids, users) {
const k_cache_version = 1; const k_cache_version = 1;
let cache = await tfrpc.rpc.databaseGet('about'); let cache = await tfrpc.rpc.databaseGet('about');
let original_cache = cache;
cache = cache ? JSON.parse(cache) : {}; cache = cache ? JSON.parse(cache) : {};
if (cache.version !== k_cache_version) { if (cache.version !== k_cache_version) {
cache = { cache = {
@ -213,7 +214,13 @@ class TfElement extends LitElement {
} }
} }
cache.last_row_id = max_row_id; cache.last_row_id = max_row_id;
await tfrpc.rpc.databaseSet('about', JSON.stringify(cache)); let new_cache = JSON.stringify(cache);
if (new_cache !== original_cache) {
let start_time = new Date();
tfrpc.rpc.databaseSet('about', new_cache).then(function() {
console.log('saving about took', (new Date() - start_time) / 1000);
});
}
users = users || {}; users = users || {};
for (let id of Object.keys(cache.about)) { for (let id of Object.keys(cache.about)) {
users[id] = Object.assign(users[id] || {}, cache.about[id]); users[id] = Object.assign(users[id] || {}, cache.about[id]);