Skip to content

Commit

Permalink
Use formatCacheKey() when deleting a key (#7362)
Browse files Browse the repository at this point in the history
  • Loading branch information
cannikin authored and jtoar committed Mar 4, 2023
1 parent 3b80087 commit 727d48a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/api/src/cache/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,20 @@ export const createCache = (

const deleteCacheKey = async (key: CacheKey) => {
let result
const cacheKey = formatCacheKey(key, prefix)

try {
await Promise.race([
(result = client.del(key as string)),
(result = client.del(cacheKey as string)),
wait(timeout).then(() => {
throw new CacheTimeoutError()
}),
])

logger?.debug(`[Cache] DEL '${key}'`)
logger?.debug(`[Cache] DEL '${cacheKey}'`)
return result
} catch (e: any) {
logger?.error(`[Cache] Error DEL '${key}': ${e.message}`)
logger?.error(`[Cache] Error DEL '${cacheKey}': ${e.message}`)
return false
}
}
Expand Down

0 comments on commit 727d48a

Please sign in to comment.