Add cache clearing feature and update UI

This commit is contained in:
Jordan Wages 2025-06-27 01:05:27 -05:00
commit 1ad1b7004d
4 changed files with 116 additions and 4 deletions

View file

@ -210,6 +210,25 @@ function cacheResult(cacheKey, matched) {
}
}
async function removeCacheEntries(keys = []) {
if (!Array.isArray(keys)) {
keys = [keys];
}
if (!gCacheLoaded) {
await loadCache();
}
let removed = false;
for (let key of keys) {
if (gCache.delete(key)) {
removed = true;
aiLog(`[AiClassifier] Removed cache entry '${key}'`, {debug: true});
}
}
if (removed) {
await saveCache();
}
}
function classifyTextSync(text, criterion, cacheKey = null) {
if (!Services?.tm?.spinEventLoopUntil) {
throw new Error("classifyTextSync requires Services");
@ -288,4 +307,4 @@ async function classifyText(text, criterion, cacheKey = null) {
}
}
export { classifyText, classifyTextSync, setConfig };
export { classifyText, classifyTextSync, setConfig, removeCacheEntries };