From ac8c66f5abe5b585a5940e172993c8e28f44ad69 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 25 Mar 2022 16:27:41 +0900 Subject: perf(server): refactor and performance improvements --- packages/backend/src/services/note/create.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'packages/backend/src/services/note/create.ts') diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index b295534cd2..f4b0d52045 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -38,8 +38,6 @@ import { endedPollNotificationQueue } from '@/queue/queues.js'; import { Cache } from '@/misc/cache.js'; import { UserProfile } from '@/models/entities/user-profile.js'; -const usersCache = new Cache(Infinity); - const mutedWordsCache = new Cache<{ userId: UserProfile['userId']; mutedWords: UserProfile['mutedWords']; }[]>(1000 * 60 * 5); type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -212,7 +210,7 @@ export default async (user: { id: User['id']; username: User['username']; host: tags = tags.filter(tag => Array.from(tag || '').length <= 128).splice(0, 32); if (data.reply && (user.id !== data.reply.userId) && !mentionedUsers.some(u => u.id === data.reply!.userId)) { - mentionedUsers.push(await usersCache.fetch(data.reply.userId, () => Users.findOneOrFail(data.reply!.userId))); + mentionedUsers.push(await Users.findOneOrFail(data.reply!.userId)); } if (data.visibility === 'specified') { @@ -225,7 +223,7 @@ export default async (user: { id: User['id']; username: User['username']; host: } if (data.reply && !data.visibleUsers.some(x => x.id === data.reply!.userId)) { - data.visibleUsers.push(await usersCache.fetch(data.reply.userId, () => Users.findOneOrFail(data.reply!.userId))); + data.visibleUsers.push(await Users.findOneOrFail(data.reply!.userId)); } } -- cgit v1.3.1-freya