UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

98 lines 2.27 kB
/** * QueryCache - Intelligent caching layer for analytics queries * * Features: * - LRU cache with configurable size * - Query normalization for better hit rates * - TTL-based expiration * - Cache key generation from query + params * - Memory usage tracking */ import { HybridQuery, AnalyticsResult } from './types.js'; interface CacheStats { hits: number; misses: number; evictions: number; hitRate: number; memoryUsage: number; entries: number; } export declare class QueryCache { private cache; private accessOrder; private stats; private readonly maxSize; private readonly defaultTTL; private readonly maxMemory; constructor(config?: { maxSize?: number; defaultTTL?: number; maxMemory?: number; }); /** * Get cached result for a query */ get(query: HybridQuery, params?: any[]): AnalyticsResult | null; /** * Store query result in cache */ set(query: HybridQuery, result: AnalyticsResult, params?: any[], ttl?: number): void; /** * Clear entire cache */ clear(): void; /** * Get cache statistics */ getStats(): CacheStats; /** * Generate normalized cache key from query */ private generateCacheKey; /** * Normalize SQL for better cache hits */ private normalizeSQL; /** * JSON replacer that sorts object keys for consistent hashing */ private sortReplacer; /** * Estimate memory size of result */ private estimateSize; /** * Check if cache entry is expired */ private isExpired; /** * Update access order for LRU */ private updateAccessOrder; /** * Evict least recently used entry */ private evictLRU; /** * Evict entries until enough memory is available */ private evictUntilMemoryAvailable; /** * Evict a specific entry */ private evict; /** * Update hit rate statistic */ private updateHitRate; /** * Start periodic cleanup of expired entries */ private startCleanupInterval; /** * Remove all expired entries */ private cleanupExpired; } export {}; //# sourceMappingURL=QueryCache.d.ts.map