Merged in feature/redis (pull request #1478)
Distributed cache * cache deleteKey now uses an options object instead of a lonely argument variable fuzzy * merge * remove debug logs and cleanup * cleanup * add fault handling * add fault handling * add pid when logging redis client creation * add identifier when logging redis client creation * cleanup * feat: add redis-api as it's own app * feature: use http wrapper for redis * feat: add the possibility to fallback to unstable_cache * Add error handling if redis cache is unresponsive * add logging for unstable_cache * merge * don't cache errors * fix: metadatabase on branchdeploys * Handle when /en/destinations throws add ErrorBoundary * Add sentry-logging when ErrorBoundary catches exception * Fix error handling for distributed cache * cleanup code * Added Application Insights back * Update generateApiKeys script and remove duplicate * Merge branch 'feature/redis' of bitbucket.org:scandic-swap/web into feature/redis * merge Approved-by: Linus Flood
This commit is contained in:
committed by
Linus Flood
parent
a8304e543e
commit
fa63b20ed0
@@ -6,6 +6,7 @@ import { startTransition, useEffect, useRef } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { login } from "@/constants/routes/handleAuth"
|
||||
import { env } from "@/env/client"
|
||||
import { SESSION_EXPIRED } from "@/server/errors/trpc"
|
||||
|
||||
import styles from "./error.module.css"
|
||||
@@ -61,6 +62,9 @@ export default function Error({
|
||||
<section className={styles.layout}>
|
||||
<div className={styles.content}>
|
||||
{intl.formatMessage({ id: "Something went wrong!" })}
|
||||
{env.NEXT_PUBLIC_NODE_ENV === "development" && (
|
||||
<pre>{error.stack || error.message}</pre>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
|
||||
@@ -25,8 +25,7 @@ export default async function CurrentContentPage({
|
||||
{
|
||||
locale: params.lang,
|
||||
url: searchParams.uri,
|
||||
},
|
||||
{ cache: "no-store" }
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.data?.all_current_blocks_page?.total) {
|
||||
@@ -39,8 +38,7 @@ export default async function CurrentContentPage({
|
||||
// This is currently to be considered a temporary solution to provide the tracking with a few values in english to align with existing reports
|
||||
const pageDataForTracking = await request<TrackingData>(
|
||||
GetCurrentBlockPageTrackingData,
|
||||
{ uid: response.data.all_current_blocks_page.items[0].system.uid },
|
||||
{ cache: "no-store" }
|
||||
{ uid: response.data.all_current_blocks_page.items[0].system.uid }
|
||||
)
|
||||
|
||||
const pageData = response.data.all_current_blocks_page.items[0]
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Lang } from "@/constants/languages"
|
||||
import { env } from "@/env/server"
|
||||
import { badRequest, internalServerError, notFound } from "@/server/errors/next"
|
||||
|
||||
import { getCacheClient } from "@/services/dataCache"
|
||||
import { generateHotelUrlTag } from "@/utils/generateTag"
|
||||
|
||||
import type { NextRequest } from "next/server"
|
||||
@@ -63,6 +64,8 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
console.info(`Revalidating hotel url tag: ${tag}`)
|
||||
revalidateTag(tag)
|
||||
const cacheClient = await getCacheClient()
|
||||
await cacheClient.deleteKey(tag, { fuzzy: true })
|
||||
|
||||
return Response.json({ revalidated: true, now: Date.now() })
|
||||
} catch (error) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Lang } from "@/constants/languages"
|
||||
import { env } from "@/env/server"
|
||||
import { badRequest, internalServerError, notFound } from "@/server/errors/next"
|
||||
|
||||
import { getCacheClient } from "@/services/dataCache"
|
||||
import { generateLoyaltyConfigTag } from "@/utils/generateTag"
|
||||
|
||||
import type { NextRequest } from "next/server"
|
||||
@@ -82,6 +83,9 @@ export async function POST(request: NextRequest) {
|
||||
console.info(`Revalidating loyalty config tag: ${tag}`)
|
||||
revalidateTag(tag)
|
||||
|
||||
const cacheClient = await getCacheClient()
|
||||
await cacheClient.deleteKey(tag, { fuzzy: true })
|
||||
|
||||
return Response.json({ revalidated: true, now: Date.now() })
|
||||
} catch (error) {
|
||||
console.error("Failed to revalidate tag(s) for loyalty config")
|
||||
|
||||
@@ -4,6 +4,7 @@ import { headers } from "next/headers"
|
||||
import { env } from "@/env/server"
|
||||
import { badRequest, internalServerError } from "@/server/errors/next"
|
||||
|
||||
import { getCacheClient } from "@/services/dataCache"
|
||||
import { generateTag } from "@/utils/generateTag"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
@@ -27,23 +28,8 @@ export async function POST() {
|
||||
const affix = headersList.get("x-affix")
|
||||
const identifier = headersList.get("x-identifier")
|
||||
const lang = headersList.get("x-lang")
|
||||
if (lang && identifier) {
|
||||
if (affix) {
|
||||
const tag = generateTag(lang as Lang, identifier, affix)
|
||||
console.info(
|
||||
`Revalidated tag for [lang: ${lang}, identifier: ${identifier}, affix: ${affix}]`
|
||||
)
|
||||
console.info(`Tag: ${tag}`)
|
||||
revalidateTag(tag)
|
||||
} else {
|
||||
const tag = generateTag(lang as Lang, identifier)
|
||||
console.info(
|
||||
`Revalidated tag for [lang: ${lang}, identifier: ${identifier}]`
|
||||
)
|
||||
console.info(`Tag: ${tag}`)
|
||||
revalidateTag(tag)
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!lang || !identifier) {
|
||||
console.info(`Missing lang and/or identifier`)
|
||||
console.info(`lang: ${lang}, identifier: ${identifier}`)
|
||||
return badRequest({
|
||||
@@ -52,6 +38,18 @@ export async function POST() {
|
||||
})
|
||||
}
|
||||
|
||||
const cacheClient = await getCacheClient()
|
||||
|
||||
const tag = generateTag(lang as Lang, identifier, affix)
|
||||
|
||||
console.info(
|
||||
`Revalidated tag for [lang: ${lang}, identifier: ${identifier}${affix ? `, affix: ${affix}` : ""}]`
|
||||
)
|
||||
console.info(`Tag: ${tag}`)
|
||||
|
||||
revalidateTag(tag)
|
||||
cacheClient.deleteKey(tag, { fuzzy: true })
|
||||
|
||||
return Response.json({ revalidated: true, now: Date.now() })
|
||||
} catch (error) {
|
||||
console.error("Failed to revalidate tag(s)")
|
||||
|
||||
@@ -10,6 +10,7 @@ import { languageSwitcherAffix } from "@/server/routers/contentstack/languageSwi
|
||||
import { affix as metadataAffix } from "@/server/routers/contentstack/metadata/utils"
|
||||
import { affix as pageSettingsAffix } from "@/server/routers/contentstack/pageSettings/utils"
|
||||
|
||||
import { getCacheClient } from "@/services/dataCache"
|
||||
import {
|
||||
generateRefsResponseTag,
|
||||
generateRefTag,
|
||||
@@ -87,23 +88,31 @@ export async function POST(request: NextRequest) {
|
||||
)
|
||||
const metadataTag = generateTag(entryLocale, entry.uid, metadataAffix)
|
||||
|
||||
const cacheClient = await getCacheClient()
|
||||
|
||||
console.info(`Revalidating refsTag: ${refsTag}`)
|
||||
revalidateTag(refsTag)
|
||||
await cacheClient.deleteKey(refsTag, { fuzzy: true })
|
||||
|
||||
console.info(`Revalidating refTag: ${refTag}`)
|
||||
revalidateTag(refTag)
|
||||
await cacheClient.deleteKey(refTag, { fuzzy: true })
|
||||
|
||||
console.info(`Revalidating tag: ${tag}`)
|
||||
revalidateTag(tag)
|
||||
await cacheClient.deleteKey(tag, { fuzzy: true })
|
||||
|
||||
console.info(`Revalidating language switcher tag: ${languageSwitcherTag}`)
|
||||
revalidateTag(languageSwitcherTag)
|
||||
await cacheClient.deleteKey(languageSwitcherTag, { fuzzy: true })
|
||||
|
||||
console.info(`Revalidating metadataTag: ${metadataTag}`)
|
||||
revalidateTag(metadataTag)
|
||||
await cacheClient.deleteKey(metadataTag, { fuzzy: true })
|
||||
|
||||
console.info(`Revalidating contentEntryTag: ${contentEntryTag}`)
|
||||
revalidateTag(contentEntryTag)
|
||||
await cacheClient.deleteKey(contentEntryTag, { fuzzy: true })
|
||||
|
||||
if (entry.breadcrumbs) {
|
||||
const breadcrumbsRefsTag = generateRefsResponseTag(
|
||||
@@ -119,9 +128,11 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
console.info(`Revalidating breadcrumbsRefsTag: ${breadcrumbsRefsTag}`)
|
||||
revalidateTag(breadcrumbsRefsTag)
|
||||
await cacheClient.deleteKey(breadcrumbsRefsTag, { fuzzy: true })
|
||||
|
||||
console.info(`Revalidating breadcrumbsTag: ${breadcrumbsTag}`)
|
||||
revalidateTag(breadcrumbsTag)
|
||||
await cacheClient.deleteKey(breadcrumbsTag, { fuzzy: true })
|
||||
}
|
||||
|
||||
if (entry.page_settings) {
|
||||
@@ -133,6 +144,7 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
console.info(`Revalidating pageSettingsTag: ${pageSettingsTag}`)
|
||||
revalidateTag(pageSettingsTag)
|
||||
await cacheClient.deleteKey(pageSettingsTag, { fuzzy: true })
|
||||
}
|
||||
|
||||
return Response.json({ revalidated: true, now: Date.now() })
|
||||
|
||||
Reference in New Issue
Block a user