add comment cache clear
This commit is contained in:
@@ -7,6 +7,7 @@ import {ConfigUI} from './Config';
|
|||||||
|
|
||||||
import './Title.css';
|
import './Title.css';
|
||||||
import {BalanceShower} from './BalanceShower';
|
import {BalanceShower} from './BalanceShower';
|
||||||
|
import {cache} from './cache';
|
||||||
|
|
||||||
const flag_re=/^\/\/setflag ([a-zA-Z0-9_]+)=(.*)$/;
|
const flag_re=/^\/\/setflag ([a-zA-Z0-9_]+)=(.*)$/;
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ const HELP_TEXT=(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
cache().clear();
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
},200);
|
},200);
|
||||||
|
|||||||
10
src/cache.js
10
src/cache.js
@@ -1,3 +1,4 @@
|
|||||||
|
const HOLE_CACHE_DB_NAME='hole_cache_db';
|
||||||
const CACHE_DB_VER=1;
|
const CACHE_DB_VER=1;
|
||||||
const MAINTENANCE_STEP=500;
|
const MAINTENANCE_STEP=500;
|
||||||
const MAINTENANCE_COUNT=5000;
|
const MAINTENANCE_COUNT=5000;
|
||||||
@@ -6,7 +7,7 @@ class Cache {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.db=null;
|
this.db=null;
|
||||||
this.added_items_since_maintenance=0;
|
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.onerror=console.error.bind(console);
|
||||||
open_req.onupgradeneeded=(event)=>{
|
open_req.onupgradeneeded=(event)=>{
|
||||||
console.log('comment cache db upgrade');
|
console.log('comment cache db upgrade');
|
||||||
@@ -93,6 +94,13 @@ class Cache {
|
|||||||
};
|
};
|
||||||
count_req.onerror=console.error.bind(console);
|
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() {
|
export function cache() {
|
||||||
|
|||||||
Reference in New Issue
Block a user