/** * Query Cache Service * * Provides caching for semantic search query results using the ICacheStore interface. * Works with both embedded (LRU-cache) and server (Redis) storage modes. * * Cache Strategy: * - Cache key: hash of (query + projectId + searchType) * - TTL: 5 minutes (default) - balances freshness with performance * - Invalidation: On file changes via sync/index * - Tags: project-based for bulk invalidation * * Benefits: * - Reduces embedding generation (~50-100ms per query) * - Reduces database queries (~20-50ms per search) * - Enables near-instant repeated queries */ export interface CachedSearchResult { results: any[]; cachedAt: number; queryHash: string; projectId: string; } export interface QueryCacheConfig { /** TTL in seconds (default: 300 = 5 minutes) */ ttlSeconds?: number; /** Whether caching is enabled (default: true) */ enabled?: boolean; /** Max cached results per query (default: 50) */ maxResults?: number; } export declare class QueryCacheService { private cacheStore; private config; private initialized; constructor(config?: QueryCacheConfig); /** * Initialize cache store from storage manager */ private ensureInitialized; /** * Generate a cache key for a search query */ private generateCacheKey; /** * Get cached search results * @returns Cached results or null if not cached/expired */ get(query: string, projectId: string, searchType?: string): Promise; /** * Cache search results */ set(query: string, projectId: string, results: any[], searchType?: string): Promise; /** * Invalidate cache for a specific project * Called when files are indexed/modified */ invalidateProject(projectId: string): Promise; /** * Invalidate cache for specific files in a project * More surgical invalidation - only clears queries that might have matched these files */ invalidateFiles(projectId: string, filePaths: string[]): Promise; /** * Get cache statistics */ getStats(): Promise<{ size: number; hits: number; misses: number; } | null>; /** * Clear all search cache entries */ clearAll(): Promise; /** * Check if caching is available and enabled */ isAvailable(): Promise; } export declare function getQueryCacheService(config?: QueryCacheConfig): QueryCacheService; export declare function resetQueryCacheService(): void; //# sourceMappingURL=query-cache-service.d.ts.map