UNPKG

sfcc-dev-mcp

Version:

MCP server for Salesforce B2C Commerce Cloud development assistance including logs, debugging, and development tools

105 lines 2.74 kB
/** * In-Memory Caching Module * * Provides efficient caching with TTL (Time-To-Live) and LRU (Least Recently Used) eviction * to reduce IO operations and improve response times for SFCC documentation queries. */ export interface CacheEntry<T> { value: T; timestamp: number; accessCount: number; lastAccessed: number; } export interface CacheOptions { maxSize?: number; ttlMs?: number; cleanupIntervalMs?: number; } export declare class InMemoryCache<T> { private cache; private readonly maxSize; private readonly ttlMs; private cleanupTimer?; constructor(options?: CacheOptions); /** * Store a value in the cache */ set(key: string, value: T): void; /** * Retrieve a value from the cache */ get(key: string): T | undefined; /** * Check if a key exists in the cache (without updating access stats) */ has(key: string): boolean; /** * Remove a specific key from the cache */ delete(key: string): boolean; /** * Clear all entries from the cache */ clear(): void; /** * Get cache statistics */ getStats(): { size: number; maxSize: number; hitRate: number; entries: Array<{ key: string; accessCount: number; age: number; }>; }; /** * Remove expired entries from the cache */ private cleanup; /** * Evict the least recently used item */ private evictLRU; /** * Cleanup resources */ destroy(): void; } /** * Multi-layer cache manager for different types of data */ export declare class CacheManager { private fileContentCache; private classDetailsCache; private searchResultsCache; private methodSearchCache; constructor(); getFileContent(key: string): string | undefined; setFileContent(key: string, content: string): void; getClassDetails(key: string): any; setClassDetails(key: string, details: any): void; getSearchResults(key: string): any; setSearchResults(key: string, results: any): void; getMethodSearch(key: string): any; setMethodSearch(key: string, results: any): void; /** * Get comprehensive cache statistics */ getAllStats(): { fileContent: ReturnType<InMemoryCache<any>['getStats']>; classDetails: ReturnType<InMemoryCache<any>['getStats']>; searchResults: ReturnType<InMemoryCache<any>['getStats']>; methodSearch: ReturnType<InMemoryCache<any>['getStats']>; }; /** * Clear all caches */ clearAll(): void; /** * Cleanup all resources */ destroy(): void; } //# sourceMappingURL=cache.d.ts.map