• Clear the search cache.

    Parameters

    • OptionalsearchQuery: string

      Optional search query to clear specific entries.

    Returns void

    export function clearSearchCache(searchQuery?: string): void {
    if (searchQuery) {
    // Clear specific cache entries
    for (const key of Object.keys(searchCache)) {
    if (key.includes(searchQuery.toLowerCase())) {
    delete searchCache[key];
    }
    }
    console.log(`Cleared search cache for: ${searchQuery}`);
    } else {
    // Clear all cache
    for (const key of Object.keys(searchCache)) {
    delete searchCache[key];
    }
    console.log("Cleared all search cache");
    }

    // Update localStorage with the cleared cache
    persistSearchCache();

    // Also clear the cache in the main process
    globalThis.electronAPI.anilist
    .clearCache(searchQuery)
    .catch((error: Error) => {
    console.error("Failed to clear main process cache:", error);
    });
    }