/** * Cache entry with result and timestamp for TTL checks. */ export interface CacheEntry { result: T; timestamp: number; } /** * Cache store interface for tool result caching. * Supports both sync and async operations for different backends (LRU, Redis, etc.) */ export interface CacheStore { /** Get cached entry by key */ get(key: string): CacheEntry | undefined | Promise | undefined>; /** Set cache entry */ set(key: string, entry: CacheEntry): void | Promise; /** Delete cache entry */ delete(key: string): void | Promise; /** Clear all entries */ clear(): void | Promise; /** Get current cache size (optional, for stats) */ size?(): number | Promise; } /** * Options for the cached() tool wrapper. */ export interface CacheOptions { /** TTL in milliseconds (default: 5 minutes) */ ttl?: number; /** Custom cache store (default: LRUCacheStore) */ store?: CacheStore; /** Custom key generator */ keyGenerator?: (toolName: string, params: unknown) => string; /** Enable debug logging for cache hits/misses */ debug?: boolean; /** Callback when cache hit occurs */ onHit?: (toolName: string, key: string) => void; /** Callback when cache miss occurs */ onMiss?: (toolName: string, key: string) => void; } /** * Cache statistics returned by getStats(). */ export interface CacheStats { /** Number of cache hits */ hits: number; /** Number of cache misses */ misses: number; /** Hit rate (0-1) */ hitRate: number; /** Current cache size */ size: number; }