feat(ADM-018): completed feature

This commit is contained in:
chattie
2026-08-17 22:23:10 +02:00
parent cf1c69fc8b
commit d595b4871f
871 changed files with 47411 additions and 281 deletions

View File

@@ -0,0 +1,20 @@
export interface CacheEntry<T> {
key: string;
value: T;
expiresAt: number;
}
export interface CacheContract {
name: string;
keyPattern: string;
ttlSeconds: number;
sourceOfTruth: string;
invalidation: string;
}
export interface CacheMetrics {
hits: number;
misses: number;
invalidations: number;
hitRatio(): number;
}

View File

@@ -0,0 +1,21 @@
export interface CacheAdapter {
get<T>(key: string): Promise<T | undefined>;
set<T>(key: string, value: T, ttlSeconds: number): Promise<void>;
invalidate(key: string): Promise<void>;
}
export interface CacheReadThrough {
read<T>(contractName: string, key: string, loader: () => Promise<T>): Promise<T>;
}
export interface CacheService extends CacheReadThrough {
listContracts(): Array<{
name: string;
keyPattern: string;
ttlSeconds: number;
sourceOfTruth: string;
invalidation: string;
}>;
invalidateByName(name: string): Promise<number>;
metrics(): { hits: number; misses: number; invalidations: number; hitRatio: number };
}