Merged in fix/cache-graphql-data (pull request #2248)

fix: add missing cache for cms data

* fix: cache cms data


Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-05-28 08:28:21 +00:00
committed by Linus Flood
parent 1d733c5ca3
commit 26b005d72a
4 changed files with 24 additions and 11 deletions

View File

@@ -3,7 +3,6 @@ import { request } from "@/lib/graphql/request"
import { notFound } from "@/server/errors/trpc"
import { createCounter } from "@/server/telemetry"
import { getCacheClient } from "@/services/dataCache"
import {
generateRefsResponseTag,
generateTag,
@@ -32,16 +31,17 @@ export async function fetchCollectionPageRefs(lang: Lang, uid: string) {
metricsGetCollectionPageRefs.start()
const cacheClient = await getCacheClient()
const cacheKey = generateRefsResponseTag(lang, uid)
const refsResponse = await cacheClient.cacheOrGet(
cacheKey,
async () =>
await request<GetCollectionPageRefsSchema>(GetCollectionPageRefs, {
locale: lang,
uid,
}),
"max"
const refsResponse = await request<GetCollectionPageRefsSchema>(
GetCollectionPageRefs,
{
locale: lang,
uid,
},
{
key: cacheKey,
ttl: "max",
}
)
if (!refsResponse.data) {