add comment cache clear

This commit is contained in:
xmcp
2020-01-10 21:28:04 +08:00
parent c22116c27c
commit f9ccbc46ae
2 changed files with 11 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import {ConfigUI} from './Config';
import './Title.css';
import {BalanceShower} from './BalanceShower';
import {cache} from './cache';
const flag_re=/^\/\/setflag ([a-zA-Z0-9_]+)=(.*)$/;
@@ -36,6 +37,7 @@ const HELP_TEXT=(
}
});
}
cache().clear();
setTimeout(()=>{
window.location.reload(true);
},200);

View File

@@ -1,3 +1,4 @@
const HOLE_CACHE_DB_NAME='hole_cache_db';
const CACHE_DB_VER=1;
const MAINTENANCE_STEP=500;
const MAINTENANCE_COUNT=5000;
@@ -6,7 +7,7 @@ class Cache {
constructor() {
this.db=null;
this.added_items_since_maintenance=0;
const open_req=indexedDB.open('hole_cache_db',CACHE_DB_VER);
const open_req=indexedDB.open(HOLE_CACHE_DB_NAME,CACHE_DB_VER);
open_req.onerror=console.error.bind(console);
open_req.onupgradeneeded=(event)=>{
console.log('comment cache db upgrade');
@@ -93,6 +94,13 @@ class Cache {
};
count_req.onerror=console.error.bind(console);
}
clear() {
if(!this.db)
return;
indexedDB.deleteDatabase(HOLE_CACHE_DB_NAME);
console.log('delete comment cache db');
}
};
export function cache() {