UNPKG

@codai/memorai-core

Version:

Simplified advanced memory engine - no tiers, just powerful semantic search with persistence

74 lines 2.05 kB
/** * Enterprise Memory Optimization Engine * Handles memory cleanup, compression, and performance optimization */ import type { VectorStore } from '../vector/VectorStore.js'; export interface OptimizationConfig { maxMemoryAge: number; maxMemoryCount: number; duplicateDetectionThreshold: number; batchSize: number; compressionEnabled: boolean; cacheTtl: number; cleanupInterval: number; lowAccessThreshold: number; lowAccessMaxAge: number; } export interface MemoryStats { totalMemories: number; totalSize: number; duplicates: number; oldMemories: number; lowAccessMemories: number; compressionRatio: number; } export declare class MemoryOptimizer { private config; private vectorStore; private cache; private isOptimizing; constructor(vectorStore: VectorStore, config?: Partial<OptimizationConfig>); /** * Comprehensive memory optimization process */ optimize(tenantId: string): Promise<MemoryStats>; /** * Remove duplicate memories based on content similarity */ private removeDuplicates; /** * Remove memories older than configured threshold */ private cleanOldMemories; /** * Remove memories with low access count */ private cleanLowAccessMemories; /** * Compress memory embeddings and metadata */ private compressMemories; /** * Optimize vector database indices */ private optimizeIndices; /** * Get comprehensive memory statistics */ private getMemoryStats; /** * Cache frequently accessed data */ getCachedData<T>(key: string): T | null; setCachedData<T>(key: string, data: T): void; /** * Start periodic optimization process */ private startPeriodicOptimization; private getAllMemories; private generateContentHash; private calculateMemorySize; private countDuplicates; private countOldMemories; private countLowAccessMemories; } //# sourceMappingURL=MemoryOptimizer.d.ts.map