UNPKG

mira-consciousness

Version:

Memory & Intelligence Retention Archive - Preserving The Spark

67 lines 2.01 kB
/** * Caching Strategy for MIRA * ========================= * * Implements a multi-level caching system to improve performance * for expensive operations like file analysis and memory searches. */ interface CacheOptions { ttl?: number; maxSize?: number; persistent?: boolean; } export declare class CacheManager { private memoryCache; private cacheDir; private maxMemorySize; private currentMemorySize; constructor(cacheDir?: string, maxMemorySize?: number); private initializeCacheDir; /** * Get cached value or compute it if not cached */ getOrCompute<T>(key: string, computeFn: () => Promise<T>, options?: CacheOptions): Promise<T>; /** * Cache file analysis results with content hash */ cacheFileAnalysis<T>(filePath: string, analysisFn: () => Promise<T>, options?: CacheOptions): Promise<T>; /** * Cache expensive glob operations */ cacheGlobResult(pattern: string, globFn: () => Promise<string[]>, options?: CacheOptions): Promise<string[]>; /** * Invalidate cache entries */ invalidate(pattern?: string): Promise<void>; /** * Get cache statistics */ getStats(): { memoryEntries: number; memorySize: number; hitRate: number; }; private isValid; private setMemoryCache; private findOldestEntry; private loadFromDisk; private saveToDisk; private sanitizeKey; private hashContent; private estimateSize; private calculateHitRate; } export declare function getCache(): CacheManager; /** * Decorator for caching method results */ export declare function cached(options?: CacheOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Memoization helper for expensive computations */ export declare function memoize<T extends (...args: any[]) => any>(fn: T, options?: { maxSize?: number; ttl?: number; }): T; export {}; //# sourceMappingURL=cache.d.ts.map