Merged in fix/site-config-revalidate (pull request #1751)
fix: site-config - use correct cache keys and invalidate them * fix: site-config - use correct cache keys and invalidate them Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -23,6 +23,7 @@ const validateJsonBody = z.object({
|
|||||||
data: z.object({
|
data: z.object({
|
||||||
content_type: z.object({
|
content_type: z.object({
|
||||||
uid: z.string(),
|
uid: z.string(),
|
||||||
|
content_type_uid: z.string(),
|
||||||
}),
|
}),
|
||||||
entry: z.object({
|
entry: z.object({
|
||||||
breadcrumbs: z
|
breadcrumbs: z
|
||||||
@@ -90,6 +91,14 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
const cacheClient = await getCacheClient()
|
const cacheClient = await getCacheClient()
|
||||||
|
|
||||||
|
const contentTypeUidTag = generateTag(
|
||||||
|
entryLocale,
|
||||||
|
content_type.content_type_uid
|
||||||
|
)
|
||||||
|
console.info(`Revalidating tag by content_type_uid: ${contentTypeUidTag}`)
|
||||||
|
revalidateTag(contentTypeUidTag)
|
||||||
|
await cacheClient.deleteKey(contentTypeUidTag, { fuzzy: true })
|
||||||
|
|
||||||
console.info(`Revalidating refsTag: ${refsTag}`)
|
console.info(`Revalidating refsTag: ${refsTag}`)
|
||||||
revalidateTag(refsTag)
|
revalidateTag(refsTag)
|
||||||
await cacheClient.deleteKey(refsTag, { fuzzy: true })
|
await cacheClient.deleteKey(refsTag, { fuzzy: true })
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import { notFound } from "@/server/errors/trpc"
|
|||||||
import { contentstackBaseProcedure, router } from "@/server/trpc"
|
import { contentstackBaseProcedure, router } from "@/server/trpc"
|
||||||
import { langInput } from "@/server/utils"
|
import { langInput } from "@/server/utils"
|
||||||
|
|
||||||
import { getCacheClient } from "@/services/dataCache"
|
|
||||||
import {
|
import {
|
||||||
generateRefsResponseTag,
|
generateRefsResponseTag,
|
||||||
generateTag,
|
generateTag,
|
||||||
@@ -605,10 +604,7 @@ export const baseQueryRouter = router({
|
|||||||
.input(langInput)
|
.input(langInput)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const lang = input.lang ?? ctx.lang
|
const lang = input.lang ?? ctx.lang
|
||||||
const cacheClient = await getCacheClient()
|
|
||||||
return await cacheClient.cacheOrGet(
|
|
||||||
generateRefsResponseTag(lang, "site_config", "root"),
|
|
||||||
async () => {
|
|
||||||
getSiteConfigRefCounter.add(1, { lang })
|
getSiteConfigRefCounter.add(1, { lang })
|
||||||
console.info(
|
console.info(
|
||||||
"contentstack.siteConfig.ref start",
|
"contentstack.siteConfig.ref start",
|
||||||
@@ -666,11 +662,8 @@ export const baseQueryRouter = router({
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const connections = getSiteConfigConnections(
|
const connections = getSiteConfigConnections(validatedSiteConfigRef.data)
|
||||||
validatedSiteConfigRef.data
|
const siteConfigUid = responseRef.data.all_site_config.items[0].system.uid
|
||||||
)
|
|
||||||
const siteConfigUid =
|
|
||||||
responseRef.data.all_site_config.items[0].system.uid
|
|
||||||
|
|
||||||
const tags = [
|
const tags = [
|
||||||
generateTagsFromSystem(lang, connections),
|
generateTagsFromSystem(lang, connections),
|
||||||
@@ -761,8 +754,5 @@ export const baseQueryRouter = router({
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"max"
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user