Add maintenance tab and cache clearing
This commit is contained in:
parent
9f701565f3
commit
db767fae48
4 changed files with 36 additions and 2 deletions
|
@ -312,6 +312,17 @@ async function removeCacheEntries(keys = []) {
|
|||
}
|
||||
}
|
||||
|
||||
async function clearCache() {
|
||||
if (!gCacheLoaded) {
|
||||
await loadCache();
|
||||
}
|
||||
if (gCache.size > 0) {
|
||||
gCache.clear();
|
||||
await saveCache();
|
||||
aiLog(`[AiClassifier] Cleared cache`, {debug: true});
|
||||
}
|
||||
}
|
||||
|
||||
function classifyTextSync(text, criterion, cacheKey = null) {
|
||||
if (!Services?.tm?.spinEventLoopUntil) {
|
||||
throw new Error("classifyTextSync requires Services");
|
||||
|
@ -396,4 +407,4 @@ async function init() {
|
|||
await loadCache();
|
||||
}
|
||||
|
||||
export { classifyText, classifyTextSync, setConfig, removeCacheEntries, getReason, getCachedResult, buildCacheKey, buildCacheKeySync, init };
|
||||
export { classifyText, classifyTextSync, setConfig, removeCacheEntries, clearCache, getReason, getCachedResult, buildCacheKey, buildCacheKeySync, init };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue