diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-10-19 09:20:19 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-10-19 09:20:19 +0900 |
| commit | 1671575d5d3d081c83f172f3439884010aafeb59 (patch) | |
| tree | 662c64008c53d3290269ed5b69ceb8e773d60837 /packages/backend/src/core/ReactionService.ts | |
| parent | perf(backend): improve my reaction population performance (diff) | |
| download | misskey-1671575d5d3d081c83f172f3439884010aafeb59.tar.gz misskey-1671575d5d3d081c83f172f3439884010aafeb59.tar.bz2 misskey-1671575d5d3d081c83f172f3439884010aafeb59.zip | |
perf(backend): ノートのリアクション情報をキャッシュすることでDBへのクエリを削減
Diffstat (limited to 'packages/backend/src/core/ReactionService.ts')
| -rw-r--r-- | packages/backend/src/core/ReactionService.ts | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts index 1458e2b173..edf433025d 100644 --- a/packages/backend/src/core/ReactionService.ts +++ b/packages/backend/src/core/ReactionService.ts @@ -187,6 +187,9 @@ export class ReactionService { await this.notesRepository.createQueryBuilder().update() .set({ reactions: () => sql, + ...(note.reactionAndUserPairCache.length < 10 ? { + reactionAndUserPairCache: () => `array_append("reactionAndUserPairCache", '${user.id}:${reaction}')`, + } : {}), }) .where('id = :id', { id: note.id }) .execute(); @@ -293,6 +296,7 @@ export class ReactionService { await this.notesRepository.createQueryBuilder().update() .set({ reactions: () => sql, + reactionAndUserPairCache: () => `array_remove("reactionAndUserPairCache", '${user.id}:${exist.reaction}')`, }) .where('id = :id', { id: note.id }) .execute(); |