codecrucible-synth
Version:
Production-Ready AI Development Platform with Multi-Voice Synthesis, Smithery MCP Integration, Enterprise Security, and Zero-Timeout Reliability
119 lines • 3.57 kB
TypeScript
/**
* CacheCoordinator - Extracted from UnifiedModelClient
* Centralizes all caching logic following Living Spiral methodology
*
* Council Perspectives Applied:
* - Performance Engineer: Intelligent TTL and hit rate optimization
* - Maintainer: Clean abstraction for cache operations
* - Security Guardian: Safe key generation and data validation
* - Explorer: Extensible cache strategies and storage backends
* - Architect: Clear separation between caching logic and client operations
*/
export interface CacheStats {
hits: number;
misses: number;
sets: number;
hitRate: string;
totalRequests: number;
}
export interface EnhancedCacheStats {
basic: any;
intelligence: CacheStats;
}
export interface CacheMetadata {
cachedAt: number;
requestType: string;
hitCount: number;
}
export interface CacheOptions {
ttl?: number;
metadata?: CacheMetadata;
}
export interface ICacheCoordinator {
get(key: string): Promise<any>;
set(key: string, value: any, options?: CacheOptions): void;
clear(): void;
destroy(): void;
generateIntelligentCacheKey(request: any, context?: any): string;
shouldUseIntelligentCache(request: any): boolean;
getIntelligentTTL(request?: any): number;
getCacheStats(): any;
getIntelligentCacheStats(): EnhancedCacheStats;
getHealthCheckCache(): Map<string, {
healthy: boolean;
timestamp: number;
}>;
setHealthCheck(key: string, healthy: boolean): void;
isHealthCheckCached(key: string, ttl: number): boolean;
}
/**
* CacheCoordinator Implementation
* Centralizes all caching operations with intelligent strategies
*/
export declare class CacheCoordinator implements ICacheCoordinator {
private cache;
private readonly CACHE_TTL;
private readonly MAX_CACHE_SIZE;
private readonly HEALTH_CACHE_TTL;
private cacheStats;
private healthCheckCache;
constructor();
/**
* Enhanced cache getter with hit tracking
*/
get(key: string): Promise<any>;
/**
* Enhanced cache setter with intelligent TTL and monitoring
*/
set(key: string, value: any, options?: CacheOptions): void;
/**
* Generate intelligent cache key based on request content and context
*/
generateIntelligentCacheKey(request: any, context?: any): string;
/**
* Normalize prompt for consistent caching
*/
private normalizePromptForCaching;
/**
* Determine intelligent TTL based on request characteristics
*/
getIntelligentTTL(request?: any): number;
/**
* Check if request should be cached
*/
shouldUseIntelligentCache(request: any): boolean;
/**
* Classify request type for intelligent caching
*/
private classifyRequestType;
/**
* Update cache statistics with hit rate calculation
*/
private updateCacheStats;
/**
* Get basic cache statistics
*/
getCacheStats(): any;
/**
* Get intelligent cache statistics with hit rates and persistence info
*/
getIntelligentCacheStats(): EnhancedCacheStats;
/**
* Health check cache management
*/
getHealthCheckCache(): Map<string, {
healthy: boolean;
timestamp: number;
}>;
setHealthCheck(key: string, healthy: boolean): void;
isHealthCheckCached(key: string, ttl?: number): boolean;
/**
* Clear all caches
*/
clear(): void;
/**
* Destroy cache coordinator and persist data
*/
destroy(): void;
}
//# sourceMappingURL=cache-coordinator.d.ts.map