Skip to content

Commit

Permalink
RedisKVCache で Redis から読み取った値を MemoryKVCache に書き戻す (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
riku6460 authored Dec 26, 2023
1 parent 086bcab commit 25829e1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/backend/src/misc/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export class RedisKVCache<T> {

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

@bindThis
Expand Down Expand Up @@ -150,7 +153,7 @@ export class RedisSingleCache<T> {
const cached = await this.redisClient.get(`singlecache:${this.name}`);
if (cached == null) return undefined;
const parsed = this.fromRedisConverter(cached);
if (parsed == null) return undefined;
if (parsed == null) return undefined;
this.memoryCache.set(parsed);
return parsed;
}
Expand Down

0 comments on commit 25829e1

Please sign in to comment.