implement no-op caches for testing

This commit is contained in:
Hazelnoot 2025-06-06 12:17:04 -04:00
parent 1d06ac4824
commit 2e486f02ff
3 changed files with 244 additions and 15 deletions

View file

@ -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)
@ -467,6 +467,22 @@ export class CacheService implements OnApplicationShutdown {
return users;
}
@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);