UNPKG

mushcode-mcp-server

Version:

A specialized Model Context Protocol server for MUSHCODE development assistance. Provides AI-powered code generation, validation, optimization, and examples for MUD development.

129 lines 2.87 kB
/** * Caching system for frequently requested examples and patterns * Provides LRU cache with TTL support and performance monitoring */ export interface CacheEntry<T> { value: T; timestamp: number; accessCount: number; lastAccessed: number; ttl?: number; } export interface CacheStats { hits: number; misses: number; hitRate: number; size: number; maxSize: number; evictions: number; totalRequests: number; } export interface CacheOptions { maxSize?: number; defaultTtl?: number; cleanupInterval?: number; } /** * LRU Cache with TTL support and performance monitoring */ export declare class LRUCache<T> { private options; private cache; private accessOrder; private stats; private cleanupTimer?; constructor(options?: CacheOptions); /** * Get value from cache */ get(key: string): T | undefined; /** * Set value in cache */ set(key: string, value: T, ttl?: number): void; /** * Check if key exists in cache (without updating access stats) */ has(key: string): boolean; /** * Delete key from cache */ delete(key: string): boolean; /** * Clear all cache entries */ clear(): void; /** * Get cache statistics */ getStats(): CacheStats; /** * Get cache keys sorted by access frequency */ getKeysByFrequency(): Array<{ key: string; accessCount: number; lastAccessed: number; }>; /** * Get cache entries that are about to expire */ getExpiringEntries(withinMs?: number): string[]; /** * Refresh TTL for a key */ refreshTtl(key: string, newTtl?: number): boolean; /** * Cleanup expired entries */ private cleanup; /** * Evict least recently used entry */ private evictLeastRecentlyUsed; /** * Move key to end of access order */ private moveToEnd; /** * Remove key from access order array */ private removeFromAccessOrder; /** * Update hit rate calculation */ private updateHitRate; /** * Destroy cache and cleanup timers */ destroy(): void; } /** * Cache manager for different types of cached data */ export declare class CacheManager { private caches; private defaultOptions; /** * Get or create a cache instance */ getCache<T>(name: string, options?: CacheOptions): LRUCache<T>; /** * Get statistics for all caches */ getAllStats(): Record<string, CacheStats>; /** * Clear all caches */ clearAll(): void; /** * Destroy all caches */ destroy(): void; /** * Get cache names */ getCacheNames(): string[]; } export declare const cacheManager: CacheManager; //# sourceMappingURL=cache.d.ts.map