From 6e7a121be03e166b9983bf3fd920e35d1bad7b81 Mon Sep 17 00:00:00 2001 From: chrisk325 Date: Fri, 6 Mar 2026 13:43:04 +0530 Subject: [PATCH] minor fix to invalidate cache logic --- src/services/trailerService.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/services/trailerService.ts b/src/services/trailerService.ts index 0bb11cae..f2fa5492 100644 --- a/src/services/trailerService.ts +++ b/src/services/trailerService.ts @@ -14,8 +14,8 @@ interface CacheEntry { } export class TrailerService { - // Cache for 3 minutes — just enough to avoid re-extracting on quick re-renders - private static readonly CACHE_TTL_MS = 30 * 1000; + // Cache for 5 seconds — just enough to avoid re-extracting on quick re-renders + private static readonly CACHE_TTL_MS = 5 * 1000; private static urlCache = new Map(); // --------------------------------------------------------------------------- @@ -114,6 +114,11 @@ export class TrailerService { return { url, title, year }; } + static invalidateCache(videoId: string): void { + this.urlCache.delete(videoId); + logger.info('TrailerService', `Cache invalidated for videoId=${videoId}`); + } + static setUseLocalServer(_useLocal: boolean): void {} static getServerStatus(): { usingLocal: boolean; localUrl: string } {