From c03d592256ab940e5468acd8048776358fce4f34 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Wed, 1 Oct 2025 12:29:16 -0400 Subject: [PATCH] manage app cache --- .../src/server/api/AuthenticateService.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/backend/src/server/api/AuthenticateService.ts b/packages/backend/src/server/api/AuthenticateService.ts index 3681602e1f..c70c50cee1 100644 --- a/packages/backend/src/server/api/AuthenticateService.ts +++ b/packages/backend/src/server/api/AuthenticateService.ts @@ -14,6 +14,7 @@ import { CacheService } from '@/core/CacheService.js'; import { isNativeUserToken } from '@/misc/token.js'; import { bindThis } from '@/decorators.js'; import { attachCallerId } from '@/misc/attach-caller-id.js'; +import { CacheManagementService, type ManagedMemoryKVCache } from '@/core/CacheManagementService.js'; export class AuthenticationError extends Error { constructor(message: string) { @@ -23,8 +24,8 @@ export class AuthenticationError extends Error { } @Injectable() -export class AuthenticateService implements OnApplicationShutdown { - private appCache: MemoryKVCache; +export class AuthenticateService { + private readonly appCache: ManagedMemoryKVCache; constructor( @Inject(DI.usersRepository) @@ -37,8 +38,9 @@ export class AuthenticateService implements OnApplicationShutdown { private appsRepository: AppsRepository, private cacheService: CacheService, + cacheManagementService: CacheManagementService, ) { - this.appCache = new MemoryKVCache(1000 * 60 * 60 * 24 * 7); // 1w + this.appCache = cacheManagementService.createMemoryKVCache(1000 * 60 * 60 * 24); // 1d } @bindThis @@ -97,14 +99,4 @@ export class AuthenticateService implements OnApplicationShutdown { } } } - - @bindThis - public dispose(): void { - this.appCache.dispose(); - } - - @bindThis - public onApplicationShutdown(signal?: string | undefined): void { - this.dispose(); - } }