diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-01-13 08:56:06 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-01-13 08:56:06 +0900 |
| commit | e00003edffc13e9d473c16c457901b35a910b13a (patch) | |
| tree | ce85359bdcbb58c64a69b7cdfac81cd3817f8dd0 /packages/backend/src/core/UserCacheService.ts | |
| parent | :art: (diff) | |
| download | sharkey-e00003edffc13e9d473c16c457901b35a910b13a.tar.gz sharkey-e00003edffc13e9d473c16c457901b35a910b13a.tar.bz2 sharkey-e00003edffc13e9d473c16c457901b35a910b13a.zip | |
refactor
Diffstat (limited to 'packages/backend/src/core/UserCacheService.ts')
| -rw-r--r-- | packages/backend/src/core/UserCacheService.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/backend/src/core/UserCacheService.ts b/packages/backend/src/core/UserCacheService.ts index 3f735c0c53..4d9ee7366d 100644 --- a/packages/backend/src/core/UserCacheService.ts +++ b/packages/backend/src/core/UserCacheService.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import Redis from 'ioredis'; import type { UsersRepository } from '@/models/index.js'; import { Cache } from '@/misc/cache.js'; -import type { CacheableLocalUser, CacheableUser, ILocalUser } from '@/models/entities/User.js'; +import type { CacheableLocalUser, CacheableUser, ILocalUser, User } from '@/models/entities/User.js'; import { DI } from '@/di-symbols.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { bindThis } from '@/decorators.js'; @@ -69,6 +69,11 @@ export class UserCacheService implements OnApplicationShutdown { } @bindThis + public findById(userId: User['id']) { + return this.userByIdCache.fetch(userId, () => this.usersRepository.findOneByOrFail({ id: userId })); + } + + @bindThis public onApplicationShutdown(signal?: string | undefined) { this.redisSubscriber.off('message', this.onMessage); } |