UNPKG

bc-code-intelligence-mcp

Version:

BC Code Intelligence MCP Server - Complete Specialist Bundle with AI-driven expert consultation, seamless handoffs, and context-preserving workflows

95 lines 2.8 kB
/** * Advanced Cache Manager with Multi-Level Caching * * Implements intelligent caching for topics, search results, and layer data * with TTL, LRU eviction, memory pressure handling, and performance analytics. */ import { AtomicTopic, TopicSearchResult } from '../types/bc-knowledge.js'; import { CacheSettings, CacheTTLSettings } from '../types/index.js'; export interface CacheStats { hits: number; misses: number; evictions: number; total_requests: number; hit_rate: number; memory_usage_bytes: number; cache_size: number; } export interface CacheEntry<T> { data: T; timestamp: number; ttl: number; access_count: number; last_accessed: number; size_bytes: number; } export declare class AdvancedCacheManager { private topicCache; private searchCache; private layerCache; private stats; private readonly config; private cleanupInterval?; constructor(config: CacheSettings); /** * Cache a topic with intelligent TTL based on source type */ cacheTopic(key: string, topic: AtomicTopic, sourceType: keyof CacheTTLSettings): void; /** * Retrieve topic from cache with hit tracking */ getTopic(key: string): AtomicTopic | null; /** * Cache search results with query-based invalidation */ cacheSearchResults(query: string, results: TopicSearchResult[], ttl?: number): void; /** * Retrieve cached search results */ getSearchResults(query: string): TopicSearchResult[] | null; /** * Cache layer data (indexes, metadata, etc.) */ cacheLayerData(layerName: string, key: string, data: any, sourceType: keyof CacheTTLSettings): void; /** * Retrieve cached layer data */ getLayerData(layerName: string, key: string): any | null; /** * Invalidate cache entries for a specific layer */ invalidateLayer(layerName: string): number; /** * Warm up cache with frequently accessed topics */ warmUpCache(topics: Array<{ key: string; topic: AtomicTopic; sourceType: keyof CacheTTLSettings; }>): Promise<void>; /** * Preload critical cache entries based on usage patterns */ preloadCriticalPaths(criticalTopics: string[]): Promise<void>; /** * Get comprehensive cache statistics */ getStats(): CacheStats; /** * Clear all caches */ clearAll(): void; /** * Shutdown and cleanup */ shutdown(): void; private getTTLForSourceType; private isExpired; private generateSearchKey; private estimateSize; private calculateTotalMemoryUsage; private enforceMemoryLimits; private startPeriodicCleanup; private cleanupExpiredEntries; } //# sourceMappingURL=cache-manager.d.ts.map