Skip to content

Commit

Permalink
fix(cache): catch redis set value errors (#21290)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Ladzaretti authored Apr 2, 2023
1 parent 82c1219 commit c5b7a45
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/util/cache/package/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ export async function set(
// Redis requires TTL to be integer, not float
const redisTTL = Math.floor(ttlMinutes * 60);

await client?.set(
getKey(namespace, key),
JSON.stringify({
compress: true,
value: await compress(JSON.stringify(value)),
expiry: DateTime.local().plus({ minutes: ttlMinutes }),
}),
{ EX: redisTTL }
);
try {
await client?.set(
getKey(namespace, key),
JSON.stringify({
compress: true,
value: await compress(JSON.stringify(value)),
expiry: DateTime.local().plus({ minutes: ttlMinutes }),
}),
{ EX: redisTTL }
);
} catch (err) {
logger.once.debug({ err }, 'Error while setting cache value');
}
}

export async function init(url: string): Promise<void> {
Expand Down

0 comments on commit c5b7a45

Please sign in to comment.