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:
committed by
Linus Flood
parent
1d733c5ca3
commit
26b005d72a
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user