/** * Cache Port * * Defines the interface for caching operations. * This is a secondary port (output port) in hexagonal architecture. */ export const CACHE_PORT = 'CachePort'; export interface CachePort { /** * Get a value from cache * Returns null if key doesn't exist */ get(key: string): Promise; /** * Set a value in cache * @param key - Cache key * @param value - Value to store * @param ttlSeconds - Time to live in seconds (optional) */ set(key: string, value: T, ttlSeconds?: number): Promise; /** * Delete a key from cache */ delete(key: string): Promise; /** * Delete multiple keys from cache */ deleteMany(keys: string[]): Promise; /** * Check if a key exists in cache */ exists(key: string): Promise; /** * Get time to live for a key (in seconds) * Returns -2 if key doesn't exist, -1 if key has no expiration */ ttl(key: string): Promise; /** * Clear all cache entries */ clear(): Promise; /** * Get cache statistics */ getStats(): Promise<{ hits: number; misses: number; hitRate: number; keyCount: number; }>; }