/** * Caching layer for recursive-llm-ts completions. * * Provides exact-match caching to avoid redundant API calls for * identical query+context pairs. Supports in-memory and file-based storage. */ export interface CacheConfig { /** Enable/disable caching (default: false) */ enabled?: boolean; /** Cache strategy (default: 'exact') */ strategy?: 'exact' | 'none'; /** Maximum number of cached entries (default: 1000) */ maxEntries?: number; /** Time-to-live in seconds (default: 3600 = 1 hour) */ ttl?: number; /** Storage backend (default: 'memory') */ storage?: 'memory' | 'file'; /** Directory for file-based cache (default: .rlm-cache) */ cacheDir?: string; } export interface CacheStats { hits: number; misses: number; size: number; hitRate: number; evictions: number; } export interface CacheProvider { get(key: string): T | undefined; set(key: string, value: T, ttl: number): void; has(key: string): boolean; delete(key: string): boolean; clear(): void; size(): number; } export declare class MemoryCache implements CacheProvider { private store; private maxEntries; constructor(maxEntries?: number); get(key: string): T | undefined; set(key: string, value: T, ttl: number): void; has(key: string): boolean; delete(key: string): boolean; clear(): void; size(): number; } export declare class FileCache implements CacheProvider { private cacheDir; private maxEntries; constructor(cacheDir?: string, maxEntries?: number); private filePath; get(key: string): T | undefined; set(key: string, value: T, ttl: number): void; has(key: string): boolean; delete(key: string): boolean; clear(): void; size(): number; } export declare class RLMCache { private provider; private config; private stats; constructor(config?: CacheConfig); /** Check if caching is enabled */ get enabled(): boolean; /** Look up a cached result */ lookup(model: string, query: string, context: string, extra?: Record): { hit: boolean; value?: T; }; /** Store a result in the cache */ store(model: string, query: string, context: string, value: T, extra?: Record): void; /** Get cache statistics */ getStats(): CacheStats; /** Clear the cache */ clear(): void; private updateHitRate; }