perf(backend): ノートのリアクション情報をキャッシュすることでDBへのクエリを削減
This commit is contained in:
parent
4d1d25e02f
commit
1671575d5d
13 changed files with 103 additions and 23 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue