From 17b83ff4c13e873b63262c349ea9c7bade0d656a Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 4 Oct 2023 08:46:27 +0900 Subject: enhance: TLキャッシュ容量を設定できるように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/NoteCreateService.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'packages/backend/src/core/NoteCreateService.ts') diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 8fb34fd637..7e1c0b5c22 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -803,6 +803,8 @@ export class NoteCreateService implements OnApplicationShutdown { @bindThis private async pushToTl(note: MiNote, user: { id: MiUser['id']; host: MiUser['host']; }) { + const meta = await this.metaService.fetch(); + const redisPipeline = this.redisForTimelines.pipeline(); if (note.channelId) { @@ -816,14 +818,14 @@ export class NoteCreateService implements OnApplicationShutdown { for (const channelFollowing of channelFollowings) { redisPipeline.xadd( `homeTimeline:${channelFollowing.followerId}`, - 'MAXLEN', '~', '200', + 'MAXLEN', '~', meta.perUserHomeTimelineCacheMax.toString(), '*', 'note', note.id); if (note.fileIds.length > 0) { redisPipeline.xadd( `homeTimelineWithFiles:${channelFollowing.followerId}`, - 'MAXLEN', '~', '100', + 'MAXLEN', '~', (meta.perUserHomeTimelineCacheMax / 2).toString(), '*', 'note', note.id); } @@ -855,14 +857,14 @@ export class NoteCreateService implements OnApplicationShutdown { redisPipeline.xadd( `homeTimeline:${following.followerId}`, - 'MAXLEN', '~', '200', + 'MAXLEN', '~', meta.perUserHomeTimelineCacheMax.toString(), '*', 'note', note.id); if (note.fileIds.length > 0) { redisPipeline.xadd( `homeTimelineWithFiles:${following.followerId}`, - 'MAXLEN', '~', '100', + 'MAXLEN', '~', (meta.perUserHomeTimelineCacheMax / 2).toString(), '*', 'note', note.id); } @@ -882,14 +884,14 @@ export class NoteCreateService implements OnApplicationShutdown { redisPipeline.xadd( `userListTimeline:${userListMembership.userListId}`, - 'MAXLEN', '~', '200', + 'MAXLEN', '~', meta.perUserListTimelineCacheMax.toString(), '*', 'note', note.id); if (note.fileIds.length > 0) { redisPipeline.xadd( `userListTimelineWithFiles:${userListMembership.userListId}`, - 'MAXLEN', '~', '100', + 'MAXLEN', '~', (meta.perUserListTimelineCacheMax / 2).toString(), '*', 'note', note.id); } @@ -898,14 +900,14 @@ export class NoteCreateService implements OnApplicationShutdown { { // 自分自身のHTL redisPipeline.xadd( `homeTimeline:${user.id}`, - 'MAXLEN', '~', '200', + 'MAXLEN', '~', meta.perUserHomeTimelineCacheMax.toString(), '*', 'note', note.id); if (note.fileIds.length > 0) { redisPipeline.xadd( `homeTimelineWithFiles:${user.id}`, - 'MAXLEN', '~', '100', + 'MAXLEN', '~', (meta.perUserHomeTimelineCacheMax / 2).toString(), '*', 'note', note.id); } @@ -916,20 +918,20 @@ export class NoteCreateService implements OnApplicationShutdown { if (note.replyId && note.replyUserId !== note.userId) { redisPipeline.xadd( `userTimelineWithReplies:${user.id}`, - 'MAXLEN', '~', '1000', + 'MAXLEN', '~', note.userHost == null ? meta.perLocalUserUserTimelineCacheMax.toString() : meta.perRemoteUserUserTimelineCacheMax.toString(), '*', 'note', note.id); } else { redisPipeline.xadd( `userTimeline:${user.id}`, - 'MAXLEN', '~', '1000', + 'MAXLEN', '~', note.userHost == null ? meta.perLocalUserUserTimelineCacheMax.toString() : meta.perRemoteUserUserTimelineCacheMax.toString(), '*', 'note', note.id); if (note.fileIds.length > 0) { redisPipeline.xadd( `userTimelineWithFiles:${user.id}`, - 'MAXLEN', '~', '500', + 'MAXLEN', '~', note.userHost == null ? (meta.perLocalUserUserTimelineCacheMax / 2).toString() : (meta.perRemoteUserUserTimelineCacheMax / 2).toString(), '*', 'note', note.id); } -- cgit v1.2.3-freya