Files
web/apps/scandic-web/services/cms/fetchAndCacheEntry.ts
Joakim Jäderberg ef3b29b9f1 Merged in fix/SW-2945-cache-timings-for-resolve-entry (pull request #2264)
Fix/SW-2945 cache timings for resolve entry

* fix: cache resolveentry() harder and revalidate on publish instead

* logging: use debug logging for requests and add logging when tll is invalid


Approved-by: Linus Flood
2025-06-02 08:35:55 +00:00

24 lines
551 B
TypeScript

import { getCacheClient } from "@/services/dataCache"
import { resolve as resolveEntry } from "@/utils/entry"
import type { Lang } from "@/constants/languages"
export const fetchAndCacheEntry = async (path: string, lang: Lang) => {
path = path || "/"
const cacheKey = `${lang}:resolveentry:${path}`
const cache = await getCacheClient()
return cache.cacheOrGet(
cacheKey,
async () => {
const { contentType, uid } = await resolveEntry(path, lang)
return {
contentType,
uid,
}
},
"max"
)
}