Merged in fix/redis-delete (pull request #3271)

feat(redis): include git hash when deleting without fuzzy

* feat(redis): include git hash when deleting without fuzzy

* Refactor


Approved-by: Joakim Jäderberg
This commit is contained in:
Linus Flood
2025-12-02 07:02:52 +00:00
parent 8f7e4b8d06
commit b1ccabb0b6
4 changed files with 40 additions and 8 deletions

View File

@@ -4,11 +4,24 @@ import { env } from "../../env/server"
import { safeTry } from "../../utils/safeTry"
import { cacheLogger } from "../logger"
import { getCacheEndpoint } from "./endpoints"
import { generateCacheKey } from "./generateCacheKey"
const API_KEY = env.REDIS_API_KEY ?? ""
export async function deleteKey(key: string, opts?: { fuzzy?: boolean }) {
export async function deleteKey(
key: string,
opts?: { fuzzy?: boolean; includeGitHashInKey?: boolean }
) {
const perf = performance.now()
const endpoint = getCacheEndpoint(key)
let cacheKey: string | undefined = key
if (opts?.includeGitHashInKey) {
cacheKey = generateCacheKey(key, {
includeGitHashInKey: true,
})
}
const endpoint = getCacheEndpoint(cacheKey)
if (opts?.fuzzy) {
endpoint.searchParams.set("fuzzy", "true")
@@ -29,7 +42,7 @@ export async function deleteKey(key: string, opts?: { fuzzy?: boolean }) {
if (response?.status !== 404) {
Sentry.captureException(error ?? new Error("Unable to DELETE cachekey"), {
extra: {
cacheKey: key,
cacheKey: cacheKey,
statusCode: response?.status,
statusText: response?.statusText,
},