UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

102 lines 3.05 kB
/** * Cache Orchestrator for Intelligent Query Engine * * Coordinates all caching components and provides a unified interface * for the IntelligentQueryEngine to interact with the caching layer. */ import { QueryNormalizer } from './QueryNormalizer.js'; import { CacheKeyGenerator, QueryContext } from './CacheKeyGenerator.js'; import { InMemoryCache, CacheStats } from './InMemoryCache.js'; import { TTLStrategy, TTLFactors } from './TTLStrategy.js'; import EventEmitter from 'events'; export interface CacheConfig { enabled: boolean; normalizer?: QueryNormalizer; keyGenerator?: CacheKeyGenerator; memoryCache?: InMemoryCache; ttlStrategy?: TTLStrategy; warmupOnStart?: boolean; statsInterval?: number; } export interface CacheEvent { type: 'hit' | 'miss' | 'set' | 'evict' | 'invalidate' | 'error'; key?: string; query?: any; metadata?: any; error?: Error; } export interface QueryResult<T = any> { data: T; cached: boolean; executionTime: number; cacheKey?: string; ttl?: number; } export declare class CacheOrchestrator extends EventEmitter { private readonly logger; private readonly enabled; private readonly normalizer; private readonly keyGenerator; private readonly memoryCache; private readonly ttlStrategy; private statsTimer?; private readonly statsInterval; constructor(config?: CacheConfig); /** * Execute a query with caching */ executeWithCache<T = any>(query: string | any, queryExecutor: (normalizedQuery: any) => Promise<T>, context?: QueryContext, options?: { bypassCache?: boolean; ttlFactors?: Partial<TTLFactors>; refreshCache?: boolean; }): Promise<QueryResult<T>>; /** * Invalidate cache entries */ invalidate(patterns: string[]): Promise<number>; /** * Invalidate cache for specific entity */ invalidateEntity(entity: string, operation?: string, context?: Partial<QueryContext>): Promise<number>; /** * Clear all cache entries */ clearCache(): void; /** * Get cache statistics */ getStats(): CacheStats | null; /** * Preload cache with common queries */ preloadQuery<T = any>(query: string | any, queryExecutor: (normalizedQuery: any) => Promise<T>, context?: QueryContext, ttlFactors?: Partial<TTLFactors>): Promise<void>; /** * Warm up cache with common queries */ private warmupCache; /** * Refresh cache entry in background */ private refreshInBackground; /** * Start periodic stats reporting */ private startStatsReporting; /** * Emit cache event */ private emitEvent; /** * Check if a query would be cached */ wouldBeCached(query: string | any): boolean; /** * Get recommended TTL for a scenario */ getRecommendedTTL(scenario: string): number; /** * Shutdown orchestrator */ shutdown(): void; } //# sourceMappingURL=CacheOrchestrator.d.ts.map