import 'server-only'; import { unstable_cache } from 'next/cache'; import { DB_MEMORY_TTL_MS, NEXT_CACHE_REVALIDATE_SECONDS } from '@/shared/config/env'; import { calculateVideoStats } from '@/entities/video/model/video'; import { listVideos } from './videoRepository'; export const VIDEO_COLLECTION_TAG = 'video-collection'; export const getCachedVideoDashboard = unstable_cache( async () => { const videos = await listVideos(); return { videos, stats: calculateVideoStats(videos), cache: { generatedAt: new Date().toISOString(), nextRevalidateSeconds: NEXT_CACHE_REVALIDATE_SECONDS, memoryTtlMs: DB_MEMORY_TTL_MS, }, }; }, ['video-dashboard-v1'], { revalidate: NEXT_CACHE_REVALIDATE_SECONDS, tags: [VIDEO_COLLECTION_TAG], }, );