UNPKG

@ui18n/angular

Version:

🅰️ Modern Angular internationalization with standalone components, signals, and dependency injection support for Angular 15+

118 lines 2.86 kB
import { CacheConfig, TranslationResult, SupportedLanguage } from './types'; /** * 优化的缓存管理器 * 实现LRU策略、内存限制、智能清理和多层持久化缓存 */ export declare class OptimizedCacheManager { private config; private memoryCache; private persistentCache?; private hits; private misses; private memoryUsage; private maxMemoryMB; private cleanupInterval?; private isNode; constructor(config: CacheConfig); /** * 获取缓存的翻译 */ get(text: string, from: SupportedLanguage, to: SupportedLanguage): Promise<TranslationResult | null>; /** * 设置缓存 */ set(text: string, from: SupportedLanguage, to: SupportedLanguage, result: TranslationResult): Promise<void>; /** * 从优化的内存缓存获取 */ private getFromOptimizedMemory; /** * 设置到优化的内存缓存 */ private setToOptimizedMemory; /** * 智能淘汰策略 */ private performSmartEviction; /** * 更新内存使用量 */ private updateMemoryUsage; /** * 估算项目大小 */ private estimateItemSize; /** * 获取缓存统计信息 */ getStats(): { hotItems: number; coldItems: number; averageAccessCount: number; totalItems: number; memoryUsageMB: number; memoryLimitMB: number; memoryUtilization: number; hits: number; misses: number; hitRate: number; type: "custom" | "hybrid" | "memory" | "localStorage" | "filesystem" | "indexeddb"; }; /** * 清理过期缓存 */ cleanup(): Promise<void>; /** * 启动定期清理 */ private startPeriodicCleanup; /** * 从localStorage获取(优化版) */ private getFromLocalStorage; /** * 设置到localStorage(优化版) */ private setToLocalStorage; /** * 智能清理localStorage */ private cleanupLocalStorage; /** * 生成缓存键 */ private generateCacheKey; /** * 字符串哈希函数 */ private hashString; /** * 清除所有缓存 */ clear(pattern?: string): Promise<void>; /** * 初始化持久化缓存 */ private initializePersistentCache; /** * 从持久化缓存获取 */ private getFromPersistentCache; /** * 设置到持久化缓存 */ private setToPersistentCache; /** * 混合缓存获取 (内存优先,持久化备份) */ private getFromHybridCache; /** * 混合缓存设置 (同时写入内存和持久化) */ private setToHybridCache; /** * 销毁缓存管理器 */ destroy(): void; } //# sourceMappingURL=optimized-cache-manager.d.ts.map