UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

77 lines 2.35 kB
/** * TTL (Time To Live) Strategy for Intelligent Query Caching * * Provides dynamic TTL configuration based on query characteristics, * data volatility, and usage patterns. */ import { NormalizedQuery } from './QueryNormalizer.js'; import { QueryContext } from './CacheKeyGenerator.js'; export interface TTLConfig { base: number; min: number; max: number; multipliers: { entity: Record<string, number>; operation: Record<string, number>; timeRange: Record<string, number>; complexity: Record<string, number>; }; } export interface TTLFactors { queryComplexity: 'simple' | 'moderate' | 'complex'; dataVolatility: 'static' | 'low' | 'medium' | 'high'; hasTimeRange: boolean; isAggregation: boolean; entityCount: number; } export declare class TTLStrategy { private readonly logger; private readonly defaultConfig; private config; constructor(customConfig?: Partial<TTLConfig>); /** * Calculate TTL for a query based on various factors */ calculateTTL(query: NormalizedQuery, context?: QueryContext, factors?: Partial<TTLFactors>): number; /** * Get time range multiplier */ private getTimeRangeMultiplier; /** * Adjust TTL based on data volatility */ private adjustForVolatility; /** * Apply special rules based on query characteristics */ private applySpecialRules; /** * Get recommended TTL for specific scenarios */ getRecommendedTTL(scenario: string): number; /** * Determine if a cached result should be refreshed based on age */ shouldRefresh(cachedAt: number, ttl: number, softRefreshRatio?: number): boolean; /** * Calculate dynamic TTL based on access patterns */ calculateDynamicTTL(baseTTL: number, accessCount: number, lastAccessInterval: number): number; /** * Get cache warmup priority based on query characteristics */ getCacheWarmupPriority(query: NormalizedQuery): number; /** * Merge configurations */ private mergeConfig; /** * Get configuration (for monitoring/debugging) */ getConfig(): Readonly<TTLConfig>; /** * Update configuration at runtime */ updateConfig(updates: Partial<TTLConfig>): void; } //# sourceMappingURL=TTLStrategy.d.ts.map