Merged in fix/SW-2401-share-cache-in-prod (pull request #1815)

Fix/SW-2401 share cache in prod

* fix: reuse cache between prod and pre-prod

* tests: add tests for generating cachePrefix

* tests: remove unnecessary reset of process.env

* tests: add tests for generateCacheKey

* fix: make sure that we don't get invalid cacheKeys

* fix: make sure that we don't get invalid cacheKeys


Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-04-17 08:57:21 +00:00
parent 213bd2c561
commit a56290edc7
8 changed files with 248 additions and 23 deletions

View File

@@ -1,14 +1,12 @@
import { env } from "@/env/server"
import { generateCacheKey } from "./generateCacheKey"
export function getCacheEndpoint(key: string) {
if (!env.REDIS_API_HOST) {
throw new Error("REDIS_API_HOST is not set")
}
const url = new URL(`/api/cache`, env.REDIS_API_HOST)
url.searchParams.set("key", encodeURIComponent(generateCacheKey(key)))
url.searchParams.set("key", encodeURIComponent(key))
return url
}