/** * Base cache provider interface * All cache providers (CLS, Memory, Redis) implement this interface */ export interface CacheProvider { /** * Get value from cache * * @param key - Cache key * @returns Cached value or null if not found */ get(key: string): Promise; /** * Set value in cache * * @param key - Cache key * @param value - Value to cache * @param ttl - Time to live in milliseconds */ set(key: string, value: T, ttl?: number): Promise; /** * Delete value from cache * * @param key - Cache key or array of keys */ delete(key: string | string[]): Promise; /** * Delete keys matching a pattern (supports wildcards) * * @param pattern - Pattern to match (e.g., 'user:*') * @returns Number of keys deleted */ deletePattern?(pattern: string): Promise; /** * Clear all cache entries */ clear(): Promise; /** * Check if a key exists in cache * * @param key - Cache key */ has(key: string): Promise; /** * Get multiple values at once * * @param keys - Array of cache keys * @returns Array of values (null for missing keys) */ mget(keys: string[]): Promise<(T | null)[]>; /** * Set multiple values at once * * @param items - Array of key-value pairs * @param ttl - Time to live in milliseconds */ mset(items: Array<{ key: string; value: any; }>, ttl?: number): Promise; /** * Get provider name */ getName(): string; } /** * Cache statistics */ export interface CacheStats { /** * Total number of get operations */ totalGets: number; /** * Number of cache hits */ hits: number; /** * Number of cache misses */ misses: number; /** * Hit rate (hits / totalGets) */ hitRate: number; /** * Stats per layer */ byLayer: Record; /** * Total number of set operations */ totalSets: number; /** * Total number of delete operations */ totalDeletes: number; /** * Total number of clear operations */ totalClears: number; }