UNPKG

mathrok

Version:

AI-powered symbolic mathematics library combining traditional Computer Algebra System (CAS) capabilities with natural language processing for math problem solving

95 lines 2.58 kB
/** * Intelligent Caching System for Mathrok * Provides multi-level caching with TTL management and performance optimization */ interface CachedResult { result: any; timestamp: number; ttl: number; hitCount: number; computationTime: number; size: number; } interface CacheStats { totalQueries: number; cacheHits: number; cacheMisses: number; hitRate: number; averageComputationTime: number; totalMemoryUsage: number; evictions: number; } interface CacheConfig { maxQueryCacheSize: number; maxComputationCacheSize: number; maxAICacheSize: number; defaultTTL: number; maxMemoryUsage: number; enableCompression: boolean; } export declare class IntelligentCache { private queryCache; private computationCache; private aiModelCache; private stats; private config; constructor(config?: Partial<CacheConfig>); /** * Get cached result by query and type */ getCachedResult(query: string, type: 'query' | 'computation' | 'ai'): Promise<CachedResult | null>; /** * Cache a result with intelligent management */ cacheResult(query: string, result: any, type: 'query' | 'computation' | 'ai', computationTime: number, ttl?: number): Promise<void>; /** * Clear specific cache type or all caches */ clearCache(type?: 'query' | 'computation' | 'ai'): void; /** * Get cache statistics */ getStats(): CacheStats; /** * Get detailed cache information */ getCacheInfo(): { queryCache: { size: number; memoryUsage: number; }; computationCache: { size: number; memoryUsage: number; }; aiCache: { size: number; memoryUsage: number; }; totalMemoryUsage: number; hitRate: number; }; /** * Optimize cache by removing expired and least used entries */ optimizeCache(): Promise<void>; private normalizeKey; private getCache; private getMaxSize; private isValidCache; private compressIfNeeded; private decompressIfNeeded; private simpleCompress; private simpleDecompress; private calculateSize; private calculateCacheMemoryUsage; private evictLeastUsed; private evictLeastRecentlyUsed; private cleanupExpiredEntries; private optimizeMemoryUsage; private updateHitRate; private updateAverageComputationTime; private startCleanupInterval; } export {}; //# sourceMappingURL=intelligent-cache.d.ts.map