Hot-fix: Write-back value in memory when it's available in redis (MisskeyIO#174)

* Write-back value in memory when it's available in redis

* Fix recursive cache

* Fix bug in case that invalid data in redis cache
This commit is contained in:
KOBA789 2023-10-06 22:41:59 +09:00 committed by GitHub
parent 3717666807
commit 533bae1e6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,7 +149,10 @@ export class RedisSingleCache<T> {
const cached = await this.redisClient.get(`singlecache:${this.name}`); const cached = await this.redisClient.get(`singlecache:${this.name}`);
if (cached == null) return undefined; 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 @bindThis