# Redis cache keys ## In active use 1. box:app:video:category:list:{categoryId} – LIST of video IDs pulled from Mongo’s videoMedia where categoryIds contains the category and status is Completed; writer is VideoCategoryCacheBuilder (video-category-cache.builder.ts (line 27)), and readers are VideoService.getVideoList/getVideosByCategoryListFallback (video.service.ts (line 824) and (line 305)). 2. box:app:video:tag:list:{categoryId}:{tagId} – LIST of video IDs filtered by tag; same builder (video-category-cache.builder.ts (line 251)) and VideoService.getVideosByTagListFallback/searchVideosByTagName (video.service.ts (line 400) and (line 1200)). 3. box:app:tag:list:{categoryId} – LIST of stringified tag objects (id, name, seq, status, timestamps, categoryId); writer VideoCategoryCacheBuilder (video-category-cache.builder.ts (line 338)), readers VideoService.getTagListForCategory and getCategoriesWithTags (video.service.ts (line 169) and (line 740)). 4. app:video:list:category:{channelId}:{categoryId}:latest – ZSET of video IDs scored by editedAt/updatedAt; writer VideoListCacheBuilder (video-list-cache.builder.ts (line 85)), reader VideoService.getVideosByCategoryWithPaging (video.service.ts (line 230)). 5. app:video:list:tag:{channelId}:{tagId}:latest – ZSET of tag-specific video IDs with the same scoring source; writer VideoListCacheBuilder (video-list-cache.builder.ts (line 138)), reader VideoService.getVideosByTagWithPaging (video.service.ts (line 400)). 6. app:video:list:home:{channelId}:{section} – LIST of the latest top-N video IDs for each section (featured/latest/editorPick); builder exists (video-list-cache.builder.ts (line 190)) but buildHomeSectionsForChannel is never invoked in buildAll (calls are commented out at (line 65)), so the key is expected by VideoService.getHomeSectionVideos (video.service.ts (line 600)) but currently empty unless manually populated. 7. app:category:all – JSON array of all categories plus their tag names (id, name, subtitle, seq, tags array from tag table); writer CategoryCacheBuilder (category-cache.builder.ts (line 1)), reader VideoService.getCategoriesWithTags (video.service.ts (line 740)). 8. app:video:recommended – JSON array of sampled completed videos mapped into RecommendedVideoItem; writer RecommendedVideosCacheBuilder (recommended-videos-cache.builder.ts (line 30)), reader VideoService.getRecommendedVideos (video.service.ts (line 1532)). 9. app:adpool:{adType} – JSON array of AdPayload entries populated from the Mongo ads and adsModule tables (status=1, valid date range, ordered by seq); writer AdPoolService.rebuildPoolForType (ad-pool.service.ts (line 59)), reader AdService.getAdForPlacement/listAdsByType (ad.service.ts (line 80)). 10. app:ad:by-id:{adId} – JSON ad payload (id, advertiser, title, content/url/cover, adType) with TTL 5 minutes; writer AdCacheWarmupService (ad-cache-warmup.service.ts (line 18)), reader AdService.getAdForPlacement (same file region). 11. app:video:detail:{videoId} – referenced by VideoService.getVideoDetail (video.service.ts (line 100)) but no current writer exists in the repo, so either the key is stale/empty or needs a fresh builder as part of the redesign. ## “Ghost” keys (no consumer/endpoints) 1. app:channel:all, app:channel:by-id:{channelId}, app:channel:with-categories:{channelId} – defined in CacheKeys (cache-keys.ts (line 18)) and written by ChannelCacheBuilder (channel-cache.builder.ts (line 24)), but no controller/service reads them today. 2. app:category:{categoryId} and app:category:by-id:{categoryId} – written alongside app:category:all (category-cache.builder.ts (line 18)) but only accessed by CategoryCacheService (category-cache.service.ts (line 1)), which isn’t injected anywhere in the workspace. 3. app:category:with-tags:{categoryId} – defined for tag refresh semantics (cache-keys.ts (line 36)) and even invalidated (cache-sync.service.ts (line 672)), yet no builder populates it or consumer reads it. 4. app:tag:all – built by TagCacheBuilder (tag-cache.builder.ts (line 1)) but only exposed through TagCacheService (tag-cache.service.ts (line 1)), which is never used. 5. Legacy list keys app:videolist:home:page:{page} and app:videolist:channel:{channelId}:page:{page} (cache-keys.ts (line 61)) are defined but not written to or read from anywhere today. ## Redis cache key redesign - Inventory every actively used key: box:app:video:category:list:{categoryId}, box:app:video:tag:list:{categoryId}:{tagId}, box:app:tag:list:{categoryId}, app:video:list:category:{channelId}:{categoryId}:latest, app:video:list:tag:{channelId}:{tagId}:latest, app:video:list:home:{channelId}:{section}, app:category:all, app:video:recommended, app:adpool:{adType}, app:ad:by-id:{adId}, plus note app:video:detail:{videoId} has no writer now (video.service.ts (line 100)). - Capture “ghost” keys still defined in cache-keys.ts and their unused consumers (app:channel:_, app:category:_, app:category:with-tags:\*, app:tag:all, legacy paginated video list keys). - Document content schemas and sources (Mongo tables/fields) alongside the services writing/reading each key to guide the redesign without breaking flows. - Schedule verification for keys whose builders are currently unused/commented (e.g., VideoListCacheBuilder.buildTagPoolsForChannel and buildHomeSectionsForChannel) before changing namespaces or semantics.