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 };
}
