summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/CustomEmojiService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-06-10 13:45:11 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-06-10 13:45:11 +0900
commite8420ad90bd290a2c10d563f6ccbffd0d4a0a97b (patch)
tree90c09fdd6ad4f8a53acb88e0a6218215816f9d47 /packages/backend/src/core/CustomEmojiService.ts
parentenhance(backend): WebSocketのPing/Pongをプロトコル制御フレーム... (diff)
downloadmisskey-e8420ad90bd290a2c10d563f6ccbffd0d4a0a97b.tar.gz
misskey-e8420ad90bd290a2c10d563f6ccbffd0d4a0a97b.tar.bz2
misskey-e8420ad90bd290a2c10d563f6ccbffd0d4a0a97b.zip
fix(backend): キャッシュが溜まり続けないように
Related #10984
Diffstat (limited to 'packages/backend/src/core/CustomEmojiService.ts')
-rw-r--r--packages/backend/src/core/CustomEmojiService.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts
index 3499df38b7..5f2ced77eb 100644
--- a/packages/backend/src/core/CustomEmojiService.ts
+++ b/packages/backend/src/core/CustomEmojiService.ts
@@ -1,4 +1,4 @@
-import { Inject, Injectable } from '@nestjs/common';
+import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
import { DataSource, In, IsNull } from 'typeorm';
import * as Redis from 'ioredis';
import { DI } from '@/di-symbols.js';
@@ -18,7 +18,7 @@ import type { Serialized } from '@/server/api/stream/types.js';
const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/;
@Injectable()
-export class CustomEmojiService {
+export class CustomEmojiService implements OnApplicationShutdown {
private cache: MemoryKVCache<Emoji | null>;
public localEmojisCache: RedisSingleCache<Map<string, Emoji>>;
@@ -349,4 +349,14 @@ export class CustomEmojiService {
this.cache.set(`${emoji.name} ${emoji.host}`, emoji);
}
}
+
+ @bindThis
+ public dispose(): void {
+ this.cache.dispose();
+ }
+
+ @bindThis
+ public onApplicationShutdown(signal?: string | undefined): void {
+ this.dispose();
+ }
}