/** * QueryCache - LRU Query Cache for AgentDB * * Provides 20-40% speedup on repeated queries through intelligent caching. * Features: * - LRU (Least Recently Used) eviction policy * - TTL (Time To Live) support for cache entries * - Thread-safe operations * - Automatic cache invalidation on writes * - Hit/miss ratio tracking * - Memory-efficient (size-based limits) */ export interface QueryCacheConfig { /** Maximum number of cache entries (default: 1000) */ maxSize?: number; /** Default TTL in milliseconds (default: 5 minutes = 300000ms) */ defaultTTL?: number; /** Enable cache (default: true) */ enabled?: boolean; /** Maximum size in bytes for cached results (default: 10MB) */ maxResultSize?: number; } export interface CacheEntry { /** Cached value */ value: T; /** Cache key */ key: string; /** Timestamp when entry was created */ timestamp: number; /** TTL for this entry in milliseconds */ ttl: number; /** Estimated size in bytes */ size: number; /** Number of times this entry was accessed */ hits: number; } export interface CacheStatistics { /** Total cache hits */ hits: number; /** Total cache misses */ misses: number; /** Hit rate percentage (0-100) */ hitRate: number; /** Current cache size */ size: number; /** Maximum cache capacity */ capacity: number; /** Number of evictions */ evictions: number; /** Total memory used (estimated bytes) */ memoryUsed: number; /** Cache entries by category */ entriesByCategory: Record; } export declare class QueryCache { private config; private cache; private accessOrder; private stats; constructor(config?: QueryCacheConfig); /** * Generate cache key from SQL query and parameters */ generateKey(sql: string, params?: any[], category?: string): string; /** * Get value from cache */ get(key: string): T | undefined; /** * Set value in cache */ set(key: string, value: T, ttl?: number): void; /** * Check if key exists in cache (without updating access time) */ has(key: string): boolean; /** * Delete specific key from cache */ delete(key: string): boolean; /** * Invalidate cache entries by category (e.g., 'episodes', 'skills') */ invalidateCategory(category: string): number; /** * Clear all cache entries */ clear(): void; /** * Get cache statistics */ getStatistics(): CacheStatistics; /** * Reset statistics (but keep cache entries) */ resetStatistics(): void; /** * Prune expired entries */ pruneExpired(): number; /** * Warm cache with common queries */ warm(warmupFn: (cache: QueryCache) => Promise): Promise; /** * Enable or disable caching */ setEnabled(enabled: boolean): void; /** * Get current configuration */ getConfig(): Readonly>; /** * Update configuration (note: doesn't clear cache) */ updateConfig(config: Partial): void; /** * Evict least recently used entry */ private evictLRU; /** * Update access order for LRU tracking */ private updateAccessOrder; /** * Remove key from access order */ private removeFromAccessOrder; /** * Simple string hash function for key generation */ private hashCode; /** * Estimate size of cached value in bytes */ private estimateSize; } //# sourceMappingURL=QueryCache.d.ts.map