Skip to content

Commit

Permalink
Hot-fix: Write-back value in memory when it's available in redis (#174)
Browse files Browse the repository at this point in the history
* Write-back value in memory when it's available in redis

* Fix recursive cache

* Fix bug in case that invalid data in redis cache
  • Loading branch information
KOBA789 authored Oct 6, 2023
1 parent 3717666 commit 533bae1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/backend/src/misc/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ export class RedisSingleCache<T> {

const cached = await this.redisClient.get(`singlecache:${this.name}`);
if (cached == null) return undefined;
return this.fromRedisConverter(cached);
const parsed = this.fromRedisConverter(cached);
if (parsed == null) return undefined;
this.memoryCache.set(parsed);
return parsed;
}

@bindThis
Expand Down

0 comments on commit 533bae1

Please sign in to comment.