UNPKG

cachly

Version:

Type-safe, production-ready in-memory cache system for Node.js and TypeScript with advanced features.

88 lines 3.45 kB
import { CacheOptions, CacheItem, CacheStats, CacheConfig, CacheEventMap, CacheEventType, WarmupItem, ProgressiveWarmupItem, DependencyWarmupItem, HealthStatus, Metrics, CircuitBreakerState, PartitionInfo, CacheGroup, BulkOperation } from './types'; export declare class Cachly { private items; private config; private cacheStats; private persistence?; private cleanupInterval?; private eventEmitter; private compressionUtil?; private circuitBreaker?; private partitioningUtil?; private monitoringUtil?; private circuitBreakerTrips; private tags; private groups; private hitHook?; private missHook?; constructor(config?: CacheConfig); set<T>(key: string, value: T, options?: Partial<CacheOptions>): Promise<void>; get<T>(key: string): Promise<T | undefined>; getOrCompute<T>(key: string, loader: () => Promise<T>, options?: Partial<CacheOptions>): Promise<T>; getOrComputeWithStale<T>(key: string, loader: () => Promise<T>, options?: Partial<CacheOptions>): Promise<T>; has(key: string): boolean; delete(key: string): void; clear(): void; stats(): CacheStats; warm(items: WarmupItem[]): Promise<void>; warmProgressive(items: ProgressiveWarmupItem[]): Promise<void>; warmWithDependencies(items: DependencyWarmupItem[]): Promise<void>; private sortByDependencies; health(): HealthStatus; metrics(): Metrics; getCircuitBreakerState(): CircuitBreakerState | undefined; getPartitionInfo(partitionId: number): PartitionInfo | undefined; getAllPartitions(): PartitionInfo[]; isBalanced(): boolean; private isExpired; private isStale; private updateDependencies; private removeDependencies; private invalidateDependents; private invalidateDependentsOnDelete; private evictIfNeeded; private evict; private evictLRU; private evictTTL; private evictLFU; private updateStats; private estimateMemoryUsage; private startCleanupInterval; private initializePersistence; destroy(): void; on<K extends CacheEventType>(event: K, listener: CacheEventMap[K]): this; off<K extends CacheEventType>(event: K, listener: CacheEventMap[K]): this; invalidateByTag(tag: string): Promise<string[]>; invalidateByTags(tags: string[]): Promise<Record<string, string[]>>; getKeysByTag(tag: string): string[]; getTagsByKey(key: string): string[]; createGroup(name: string, config?: Partial<CacheConfig>): CacheGroup; addToGroup(groupName: string, key: string): boolean; removeFromGroup(groupName: string, key: string): boolean; getGroupKeys(groupName: string): string[]; deleteGroup(groupName: string): boolean; bulk(operation: BulkOperation): Promise<any>; getKeys(pattern?: string): string[]; getKeysByPattern(pattern: string): string[]; getItemsByPattern(pattern: string): Array<{ key: string; item: CacheItem; }>; getTopKeys(limit?: number): Array<{ key: string; accessCount: number; }>; getLeastUsedKeys(limit?: number): Array<{ key: string; accessCount: number; }>; getKeysByAge(limit?: number): Array<{ key: string; age: number; }>; private updateTags; private removeTags; setHitHook(hook: (key: string) => void): void; setMissHook(hook: (key: string) => void): void; } //# sourceMappingURL=Cachly.d.ts.map