summaryrefslogtreecommitdiff
path: root/packages/backend/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/core')
-rw-r--r--packages/backend/src/core/CacheService.ts22
1 files changed, 19 insertions, 3 deletions
diff --git a/packages/backend/src/core/CacheService.ts b/packages/backend/src/core/CacheService.ts
index ae24a9721f..2c136eac2b 100644
--- a/packages/backend/src/core/CacheService.ts
+++ b/packages/backend/src/core/CacheService.ts
@@ -28,7 +28,7 @@ export interface CachedTranslation {
text: string | undefined;
}
-interface CachedTranslationEntity {
+export interface CachedTranslationEntity {
l?: string;
t?: string;
u?: number;
@@ -46,8 +46,8 @@ export class CacheService implements OnApplicationShutdown {
public userBlockedCache: QuantumKVCache<Set<string>>; // NOTE: 「被」Blockキャッシュ
public renoteMutingsCache: QuantumKVCache<Set<string>>;
public userFollowingsCache: QuantumKVCache<Record<string, Pick<MiFollowing, 'withReplies'> | undefined>>;
- private readonly userFollowStatsCache = new MemoryKVCache<FollowStats>(1000 * 60 * 10); // 10 minutes
- private readonly translationsCache: RedisKVCache<CachedTranslationEntity>;
+ protected userFollowStatsCache = new MemoryKVCache<FollowStats>(1000 * 60 * 10); // 10 minutes
+ protected translationsCache: RedisKVCache<CachedTranslationEntity>;
constructor(
@Inject(DI.redis)
@@ -468,6 +468,22 @@ export class CacheService implements OnApplicationShutdown {
}
@bindThis
+ public clear(): void {
+ this.userByIdCache.clear();
+ this.localUserByNativeTokenCache.clear();
+ this.localUserByIdCache.clear();
+ this.uriPersonCache.clear();
+ this.userProfileCache.clear();
+ this.userMutingsCache.clear();
+ this.userBlockingCache.clear();
+ this.userBlockedCache.clear();
+ this.renoteMutingsCache.clear();
+ this.userFollowingsCache.clear();
+ this.userFollowStatsCache.clear();
+ this.translationsCache.clear();
+ }
+
+ @bindThis
public dispose(): void {
this.internalEventService.off('userChangeSuspendedState', this.onUserEvent);
this.internalEventService.off('userChangeDeletedState', this.onUserEvent);