Add maintenance tab and cache clearing

This commit is contained in:
Jordan Wages 2025-06-29 02:46:49 -05:00
commit db767fae48
4 changed files with 36 additions and 2 deletions

View file

@ -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 };