summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/AuthenticateService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-04-04 17:32:09 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-04-04 17:32:09 +0900
commitecaf152b4a6eb702375debaef0dddc2cca798116 (patch)
tree85b2ca34a67ad66368fea84d0462b5c109b22415 /packages/backend/src/server/api/AuthenticateService.ts
parentrefactor(backend): rename Cache -> MemoryCache (diff)
downloadsharkey-ecaf152b4a6eb702375debaef0dddc2cca798116.tar.gz
sharkey-ecaf152b4a6eb702375debaef0dddc2cca798116.tar.bz2
sharkey-ecaf152b4a6eb702375debaef0dddc2cca798116.zip
enhance(backend): improve cache
Diffstat (limited to 'packages/backend/src/server/api/AuthenticateService.ts')
-rw-r--r--packages/backend/src/server/api/AuthenticateService.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/backend/src/server/api/AuthenticateService.ts b/packages/backend/src/server/api/AuthenticateService.ts
index cd6bce9ef9..6548c475b2 100644
--- a/packages/backend/src/server/api/AuthenticateService.ts
+++ b/packages/backend/src/server/api/AuthenticateService.ts
@@ -5,7 +5,7 @@ import type { LocalUser } from '@/models/entities/User.js';
import type { AccessToken } from '@/models/entities/AccessToken.js';
import { MemoryKVCache } from '@/misc/cache.js';
import type { App } from '@/models/entities/App.js';
-import { UserCacheService } from '@/core/UserCacheService.js';
+import { CacheService } from '@/core/CacheService.js';
import isNativeToken from '@/misc/is-native-token.js';
import { bindThis } from '@/decorators.js';
@@ -30,7 +30,7 @@ export class AuthenticateService {
@Inject(DI.appsRepository)
private appsRepository: AppsRepository,
- private userCacheService: UserCacheService,
+ private cacheService: CacheService,
) {
this.appCache = new MemoryKVCache<App>(Infinity);
}
@@ -42,7 +42,7 @@ export class AuthenticateService {
}
if (isNativeToken(token)) {
- const user = await this.userCacheService.localUserByNativeTokenCache.fetch(token,
+ const user = await this.cacheService.localUserByNativeTokenCache.fetch(token,
() => this.usersRepository.findOneBy({ token }) as Promise<LocalUser | null>);
if (user == null) {
@@ -67,7 +67,7 @@ export class AuthenticateService {
lastUsedAt: new Date(),
});
- const user = await this.userCacheService.localUserByIdCache.fetch(accessToken.userId,
+ const user = await this.cacheService.localUserByIdCache.fetch(accessToken.userId,
() => this.usersRepository.findOneBy({
id: accessToken.userId,
}) as Promise<LocalUser>);