Merged in fix/resolve-entry-clearing-cache (pull request #2445)
fix: use shared cache key when revalidating urls * fix: use shared cache key when revalidating urls Approved-by: Linus Flood
This commit is contained in:
@@ -12,6 +12,7 @@ import { languageSwitcherAffix } from "@/server/routers/contentstack/languageSwi
|
|||||||
import { affix as metadataAffix } from "@/server/routers/contentstack/metadata/utils"
|
import { affix as metadataAffix } from "@/server/routers/contentstack/metadata/utils"
|
||||||
import { affix as pageSettingsAffix } from "@/server/routers/contentstack/pageSettings/utils"
|
import { affix as pageSettingsAffix } from "@/server/routers/contentstack/pageSettings/utils"
|
||||||
|
|
||||||
|
import { resolveEntryCacheKey } from "@/utils/entry"
|
||||||
import {
|
import {
|
||||||
generateRefsResponseTag,
|
generateRefsResponseTag,
|
||||||
generateRefTag,
|
generateRefTag,
|
||||||
@@ -121,8 +122,10 @@ export async function POST(request: NextRequest) {
|
|||||||
await cacheClient.deleteKey(contentEntryTag, { fuzzy: true })
|
await cacheClient.deleteKey(contentEntryTag, { fuzzy: true })
|
||||||
|
|
||||||
if (entry.url) {
|
if (entry.url) {
|
||||||
console.info(`Revalidating url: ${entry.url}`)
|
const resolveEntryTag = resolveEntryCacheKey(entryLocale, entry.url)
|
||||||
await cacheClient.deleteKey(entry.url, { fuzzy: true })
|
console.info(`Revalidating url: ${resolveEntryTag}`)
|
||||||
|
|
||||||
|
await cacheClient.deleteKey(resolveEntryTag, { fuzzy: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.breadcrumbs) {
|
if (entry.breadcrumbs) {
|
||||||
|
|||||||
@@ -9,12 +9,16 @@ import { internalServerError } from "@/server/errors/next"
|
|||||||
|
|
||||||
import { validateEntryResolveSchema } from "@/types/requests/entry"
|
import { validateEntryResolveSchema } from "@/types/requests/entry"
|
||||||
|
|
||||||
|
export function resolveEntryCacheKey(lang: Lang, url: string) {
|
||||||
|
return `${lang}:${url}:resolveentry`
|
||||||
|
}
|
||||||
export async function resolve(url: string, lang = Lang.en) {
|
export async function resolve(url: string, lang = Lang.en) {
|
||||||
const variables = { locale: lang, url: url || "/" }
|
const variables = { locale: lang, url: url || "/" }
|
||||||
|
|
||||||
|
const cacheKey = resolveEntryCacheKey(variables.locale, variables.url)
|
||||||
|
|
||||||
// The maximum amount of content types you can query is 6, therefor more
|
// The maximum amount of content types you can query is 6, therefor more
|
||||||
// than that is being batched
|
// than that is being batched
|
||||||
const cacheKey = `${lang}:${url}:resolveentry`
|
|
||||||
const response = await batchRequest([
|
const response = await batchRequest([
|
||||||
{
|
{
|
||||||
document: EntryByUrlBatch1,
|
document: EntryByUrlBatch1,
|
||||||
|
|||||||
Reference in New Issue
Block a user