feat: redis debug

This commit is contained in:
DIYgod 2023-08-01 10:00:45 +01:00
parent 8792d9218e
commit 45760405be
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -49,7 +49,12 @@ export async function cacheGet(options: {
} else {
redisKey = options.key
}
const cacheValue = await redis.get(redisKey)
let cacheValue
try {
cacheValue = await redis.get(redisKey)
} catch (error) {
console.error("Redis get error: ", error)
}
if (cacheValue && cacheValue !== "undefined" && cacheValue !== "null") {
if (!options.noUpdate) {
setTimeout(() => {
@ -67,6 +72,7 @@ export async function cacheGet(options: {
}
return JSON.parse(cacheValue)
} else {
console.debug("cache miss", redisKey)
if (options.allowEmpty) {
options.getValueFun().then((value) => {
if (value) {