cache-keys.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // libs/common/src/cache/cache-keys.ts
  2. import type { AdType } from '../ads/ad-types';
  3. /**
  4. * Video sort key type for video listing and pooling.
  5. */
  6. export type VideoSortKey = 'latest' | 'popular' | 'manual';
  7. /**
  8. * Video home section key type for home page sections.
  9. */
  10. export type VideoHomeSectionKey = 'featured' | 'latest' | 'editorPick';
  11. export const CacheKeys = {
  12. // ─────────────────────────────────────────────
  13. // CHANNELS
  14. // ─────────────────────────────────────────────
  15. appChannelAll: 'box:app:channel:all',
  16. appChannelById: (channelId: string | number): string =>
  17. `box:app:channel:by-id:${channelId}`,
  18. appChannelWithCategories: (channelId: string | number): string =>
  19. `box:app:channel:with-categories:${channelId}`,
  20. // ─────────────────────────────────────────────
  21. // CATEGORIES
  22. // ─────────────────────────────────────────────
  23. appCategory: (categoryId: string | number): string =>
  24. `box:app:category:${categoryId}`,
  25. appCategoryAll: 'box:app:category:all',
  26. appCategoryById: (categoryId: string | number): string =>
  27. `box:app:category:by-id:${categoryId}`,
  28. appCategoryWithTags: (categoryId: string | number): string =>
  29. `box:app:category:with-tags:${categoryId}`,
  30. // ─────────────────────────────────────────────
  31. // TAGS
  32. // ─────────────────────────────────────────────
  33. appTagAll: 'box:app:tag:all',
  34. appTagByCategoryKey: (categoryId: string | number): string =>
  35. `box:app:tag:list:${categoryId}`,
  36. // ─────────────────────────────────────────────
  37. // ADS
  38. // ─────────────────────────────────────────────
  39. // ─────────────────────────────────────────────
  40. // AD POOLS (AdType-based)
  41. // ─────────────────────────────────────────────
  42. appAdPoolByType: (adType: AdType | string): string =>
  43. `box:app:adpool:${adType}`,
  44. // ─────────────────────────────────────────────
  45. // VIDEO LISTS
  46. // ─────────────────────────────────────────────
  47. appHomeVideoPage: (page: number): string =>
  48. `box:app:videolist:home:page:${page}`,
  49. appChannelVideoPage: (channelId: string | number, page: number): string =>
  50. `box:app:videolist:channel:${channelId}:page:${page}`,
  51. // ─────────────────────────────────────────────
  52. // VIDEO DETAILS & METADATA
  53. // ─────────────────────────────────────────────
  54. appVideoDetailKey: (videoId: string): string =>
  55. `box:app:video:detail:${videoId}`,
  56. appVideoPayloadKey: (videoId: string): string =>
  57. `box:app:video:payload:${videoId}`,
  58. appVideoCategoryListKey: (categoryId: string): string =>
  59. `box:app:video:category:list:${categoryId}`,
  60. appVideoTagListKey: (categoryId: string, tagId: string): string =>
  61. `box:app:video:tag:list:${categoryId}:${tagId}`,
  62. // ─────────────────────────────────────────────
  63. // VIDEO POOLS
  64. // ─────────────────────────────────────────────
  65. appVideoCategoryPoolKey: (
  66. channelId: string,
  67. categoryId: string,
  68. sort: VideoSortKey,
  69. ): string => `box:app:video:list:category:${channelId}:${categoryId}:${sort}`,
  70. appVideoTagPoolKey: (
  71. channelId: string,
  72. tagId: string,
  73. sort: VideoSortKey,
  74. ): string => `box:app:video:list:tag:${channelId}:${tagId}:${sort}`,
  75. appVideoHomeSectionKey: (
  76. channelId: string,
  77. section: string,
  78. ): string => `box:app:video:list:home:${channelId}:${section}`,
  79. // ─────────────────────────────────────────────
  80. // RECOMMENDED VIDEOS
  81. // ─────────────────────────────────────────────
  82. appRecommendedVideos: 'box:app:video:recommended',
  83. appVideoLatest: 'box:app:video:latest',
  84. appVideoList: 'box:app:video:list',
  85. appGuessList: 'box:app:video:guess:',
  86. };