/** * @holoscript/core LOD Cache * * LRU cache for LOD mesh buffers with compression support. * Manages memory budget, eviction policy, and texture streaming coordination. */ import type { MeshData } from './LODGenerator'; export interface LODCacheOptions { /** Maximum memory budget in bytes (default: 512MB) */ maxMemoryBytes: number; /** Enable compression (default: true) */ enableCompression: boolean; /** Compression format (default: 'draco') */ compressionFormat: 'draco' | 'meshopt' | 'none'; /** Compression quality (1-10, default: 7) */ compressionQuality: number; /** Enable texture streaming coordination (default: true) */ enableTextureStreaming: boolean; /** Debug mode (default: false) */ debug: boolean; } export declare const DEFAULT_LOD_CACHE_OPTIONS: LODCacheOptions; export interface CacheEntry { /** Unique key */ key: string; /** Mesh data */ meshData: MeshData; /** Size in memory (bytes) */ size: number; /** Compressed data (if compressed) */ compressedData?: Uint8Array; /** Is compressed */ compressed: boolean; /** Access count */ accessCount: number; /** Last access timestamp */ lastAccess: number; /** Creation timestamp */ created: number; /** Associated textures */ textures: string[]; } export interface CacheMetrics { /** Total entries in cache */ entryCount: number; /** Total memory used (bytes) */ memoryUsed: number; /** Memory budget (bytes) */ memoryBudget: number; /** Cache hit count */ hits: number; /** Cache miss count */ misses: number; /** Total evictions */ evictions: number; /** Hit rate (0-1) */ hitRate: number; /** Average entry size (bytes) */ averageEntrySize: number; /** Compression ratio (0-1, if enabled) */ compressionRatio: number; } export type CacheEventType = 'entryAdded' | 'entryEvicted' | 'entryAccessed' | 'budgetExceeded' | 'compressionComplete'; export interface CacheEvent { type: CacheEventType; key: string; size?: number; timestamp: number; } export type CacheEventHandler = (event: CacheEvent) => void; export declare class LODCache { private options; private entries; private head; private tail; private metrics; private eventHandlers; private compression; constructor(options?: Partial); /** * Get entry from cache */ get(key: string): MeshData | undefined; /** * Add or update entry in cache */ set(key: string, meshData: MeshData, textures?: string[]): Promise; /** * Remove entry from cache */ remove(key: string): boolean; /** * Check if key exists in cache */ has(key: string): boolean; /** * Clear entire cache */ clear(): void; /** * Evict least recently used entry */ private evictLRU; /** * Evict entries until target memory is reached */ evictToMemory(targetMemory: number): Promise; /** * Evict entries matching predicate */ evictMatching(predicate: (entry: CacheEntry) => boolean): number; private addToFront; private removeNode; private moveToFront; /** * Compress mesh data */ private compressMesh; /** * Decompress mesh data */ private decompressMesh; /** * Calculate mesh size in bytes */ private calculateMeshSize; private createMetrics; private updateHitRate; private updateAverageEntrySize; private updateCompressionRatio; /** * Get cache metrics */ getMetrics(): CacheMetrics; /** * Get all cached keys */ getKeys(): string[]; /** * Get entry info without accessing (no LRU update) */ peek(key: string): CacheEntry | undefined; /** * Get cache size */ get size(): number; /** * Get memory usage percentage (0-1) */ getMemoryUsagePercent(): number; /** * Get available memory */ getAvailableMemory(): number; on(eventType: CacheEventType, handler: CacheEventHandler): () => void; private emit; /** * Get current options */ getOptions(): LODCacheOptions; /** * Update cache options */ setOptions(options: Partial): Promise; } /** * Create LOD cache with default options */ export declare function createLODCache(options?: Partial): LODCache; /** * Create LOD cache optimized for mobile */ export declare function createMobileLODCache(): LODCache; /** * Create LOD cache optimized for desktop */ export declare function createDesktopLODCache(): LODCache; /** * Format bytes to human-readable string */ export declare function formatBytes(bytes: number): string; //# sourceMappingURL=LODCache.d.ts.map