import { getSiteContent } from "@/lib/db"; import type { SiteContent } from "@/types/content"; let cached: { data: SiteContent; expiresAt: number } | null = null; const CACHE_TTL = 5 * 60 * 1000; // 5 minutes export function getContent(): SiteContent | null { const now = Date.now(); if (cached && now < cached.expiresAt) { return cached.data; } try { const content = getSiteContent(); if (content) { cached = { data: content, expiresAt: now + CACHE_TTL }; return content; } return null; } catch { return null; } } /** Invalidate the content cache (call after admin edits). */ export function invalidateContentCache() { cached = null; }