import { IEmbeddingGenerator } from '../interfaces/IEmbeddingGenerator.js'; import { IVectorStore } from '../interfaces/IVectorStore.js'; export interface CacheEntry { key: string; value: string; compressedSize: number; originalSize: number; hitCount: number; createdAt: number; lastAccessedAt: number; } export interface CacheStats { totalEntries: number; totalHits: number; totalMisses: number; hitRate: number; totalCompressedSize: number; totalOriginalSize: number; compressionRatio: number; semanticHits?: number; semanticHitRate?: number; } export interface SemanticCachingConfig { similarityThreshold?: number; topK?: number; enabled?: boolean; } export declare class CacheEngine { private db; private memoryCache; private dbPath; private stats; private embeddingGenerator?; private vectorStore?; private semanticConfig; constructor(dbPath?: string, maxMemoryItems?: number, embeddingGenerator?: IEmbeddingGenerator, vectorStore?: IVectorStore, semanticConfig?: SemanticCachingConfig); /** * Get a value from cache (synchronous, exact match only) * For backward compatibility, this method only performs exact key matching * Use getWithSemantic() for semantic similarity search */ get(key: string): string | null; /** * Get a value from cache with semantic matching enabled * First tries exact key match, then semantic similarity if enabled */ getWithSemantic(key: string): Promise; /** * Get a value from cache using exact key match (synchronous) */ private getExact; /** * Get a value from cache using semantic similarity matching * Searches for similar queries and returns the closest match above threshold */ private getSemanticMatch; /** * Get a value from cache with metadata (including compression info) */ getWithMetadata(key: string): { content: string; compressedSize: number; } | null; /** * Set a value in cache (synchronous, without semantic embedding) * For backward compatibility */ set(key: string, value: string, originalSize: number, compressedSize: number): void; /** * Set a value in cache with semantic embedding * Also generates and stores embedding if semantic caching is enabled */ setWithSemantic(key: string, value: string, originalSize: number, compressedSize: number): Promise; /** * Delete a value from cache (synchronous) */ delete(key: string): boolean; /** * Delete a value from cache with semantic embedding removal * Also removes the embedding if semantic caching is enabled */ deleteWithSemantic(key: string): Promise; /** * Clear all cache (synchronous) */ clear(): void; /** * Clear all cache including vector store * Also clears the vector store if semantic caching is enabled */ clearWithSemantic(): Promise; /** * Get cache statistics */ getStats(): CacheStats; /** * Evict least recently used entries to stay under size limit */ evictLRU(maxSizeBytes: number): number; /** * Get all cache entries (for debugging/monitoring) */ getAllEntries(): CacheEntry[]; /** * Update hit count and last accessed time */ private updateHitCount; /** * Get the database path currently in use */ getDatabasePath(): string; /** * Close database connection */ close(): void; } //# sourceMappingURL=cache-engine.d.ts.map