/** * LRU Cache with TTL for Delphi Web Search * * Provides caching for web search results and page fetches * to avoid duplicate API calls and improve performance. */ /** * A generic LRU (Least Recently Used) cache with time-to-live (TTL) expiration. * - Entries expire after the TTL period * - When max size is reached, least recently used entries are evicted */ export declare class LRUCache { private cache; private readonly maxSize; private readonly defaultTTL; private hits; private misses; /** * Create a new LRU cache. * @param maxSize Maximum number of entries (default 100) * @param defaultTTLMs Default time-to-live in milliseconds (default 24 hours) */ constructor(maxSize?: number, defaultTTLMs?: number); /** * Get a value from the cache. * Returns undefined if not found or expired. * Accessing a key moves it to the "most recently used" position. */ get(key: string): T | undefined; /** * Set a value in the cache. * If cache is full, the least recently used entry is evicted. * @param key Cache key * @param value Value to cache * @param ttlMs Optional TTL override in milliseconds */ set(key: string, value: T, ttlMs?: number): void; /** * Check if a key exists and is not expired. */ has(key: string): boolean; /** * Delete a key from the cache. */ delete(key: string): boolean; /** * Clear all entries from the cache. */ clear(): void; /** * Get cache statistics. */ stats(): { size: number; maxSize: number; hits: number; misses: number; hitRate: number; }; /** * Clean up expired entries. * Call this periodically to free memory from expired entries. */ cleanup(): number; } export declare const searchCache: LRUCache; export declare const pageCache: LRUCache; /** * Generate a cache key for search queries. * Normalizes the query for better cache hit rates. */ export declare function searchCacheKey(query: string): string; /** * Generate a cache key for page fetches. */ export declare function pageCacheKey(url: string): string; //# sourceMappingURL=cache.d.ts.map