mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 16:26:44 -06:00
カスタム絵文字のキャッシュ時に"{}"が入ってしまう問題を修正 (#10573)
This commit is contained in:
parent
838625edcd
commit
0702f9775a
2 changed files with 4 additions and 8 deletions
|
@ -43,12 +43,8 @@ export class CustomEmojiService {
|
|||
lifetime: 1000 * 60 * 30, // 30m
|
||||
memoryCacheLifetime: 1000 * 60 * 3, // 3m
|
||||
fetcher: () => this.emojisRepository.find({ where: { host: IsNull() } }).then(emojis => new Map(emojis.map(emoji => [emoji.name, emoji]))),
|
||||
toRedisConverter: (value) => JSON.stringify(value.values()),
|
||||
fromRedisConverter: (value) => {
|
||||
// 原因不明だが配列以外が入ってくることがあるため
|
||||
if (!Array.isArray(JSON.parse(value))) return undefined;
|
||||
return new Map(JSON.parse(value).map((x: Emoji) => [x.name, x]));
|
||||
}, // TODO: Date型の変換
|
||||
toRedisConverter: (value) => JSON.stringify(Array.from(value.values())),
|
||||
fromRedisConverter: (value) => new Map(JSON.parse(value).map((x: Emoji) => [x.name, x])), // TODO: Date型の変換
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ export class RedisKVCache<T> {
|
|||
private memoryCache: MemoryKVCache<T>;
|
||||
private fetcher: (key: string) => Promise<T>;
|
||||
private toRedisConverter: (value: T) => string;
|
||||
private fromRedisConverter: (value: string) => T | undefined; // undefined means no cache
|
||||
private fromRedisConverter: (value: string) => T;
|
||||
|
||||
constructor(redisClient: RedisKVCache<T>['redisClient'], name: RedisKVCache<T>['name'], opts: {
|
||||
lifetime: RedisKVCache<T>['lifetime'];
|
||||
|
@ -92,7 +92,7 @@ export class RedisSingleCache<T> {
|
|||
private memoryCache: MemorySingleCache<T>;
|
||||
private fetcher: () => Promise<T>;
|
||||
private toRedisConverter: (value: T) => string;
|
||||
private fromRedisConverter: (value: string) => T | undefined; // undefined means no cache
|
||||
private fromRedisConverter: (value: string) => T;
|
||||
|
||||
constructor(redisClient: RedisSingleCache<T>['redisClient'], name: RedisSingleCache<T>['name'], opts: {
|
||||
lifetime: RedisSingleCache<T>['lifetime'];
|
||||
|
|
Loading…
Reference in a new issue