clean geocache

This commit is contained in:
2026-03-07 00:53:21 +01:00
parent 2f16721a93
commit c564ac8b69
2 changed files with 20 additions and 1 deletions
+18
View File
@@ -53,5 +53,23 @@ export const StorageService = {
const key = `geo_${ip.replace(/:/g, '_')}`;
const entry: CacheEntry = { data, timestamp: Date.now() };
await browser.storage.local.set({ [key]: entry });
},
async cleanExpiredGeoCache(): Promise<void> {
const res = await browser.storage.local.get(null);
const keysToRemove: string[] = [];
for (const [key, value] of Object.entries(res)) {
if (key.startsWith('geo_')) {
const entry = value as CacheEntry;
if (Date.now() - entry.timestamp > CACHE_TTL) {
keysToRemove.push(key);
}
}
}
if (keysToRemove.length > 0) {
await browser.storage.local.remove(keysToRemove);
}
}
};
+2 -1
View File
@@ -12,7 +12,8 @@ export default defineConfig({
'tabs',
'webRequest',
'webNavigation',
'storage'
'storage',
'alarms'
],
host_permissions: [
'<all_urls>',