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
24 lines
551 B
TypeScript
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"
|
|
)
|
|
}
|