Skip to content

Commit

Permalink
Use formatCacheKey() when deleting a key (redwoodjs#7362)
Browse files Browse the repository at this point in the history
  • Loading branch information
cannikin committed Mar 2, 2023
1 parent 8996510 commit af85f10
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 af85f10

Please sign in to comment.