@dbs-portal/core-module-registry
Version:
Core module registry system for automatic module discovery and registration
119 lines • 2.52 kB
TypeScript
/**
* Module Cache
*
* High-performance caching system for module registry with TTL support,
* memory management, and cache statistics.
*/
export interface CacheOptions {
defaultTTL?: number;
maxSize?: number;
cleanupInterval?: number;
enableStats?: boolean;
}
export interface CacheStats {
hits: number;
misses: number;
sets: number;
deletes: number;
evictions: number;
size: number;
hitRate: number;
}
export declare class ModuleCache {
private cache;
private options;
private stats;
private cleanupTimer;
constructor(defaultTTL?: number, options?: CacheOptions);
/**
* Get value from cache
*/
get<T = any>(key: string): T | null;
/**
* Set value in cache
*/
set<T = any>(key: string, value: T, ttl?: number): void;
/**
* Check if key exists in cache (without updating access time)
*/
has(key: string): boolean;
/**
* Delete value from cache
*/
delete(key: string): boolean;
/**
* Clear all cache entries
*/
clear(): void;
/**
* Get cache size
*/
size(): number;
/**
* Get all cache keys
*/
keys(): string[];
/**
* Get cache statistics
*/
getStats(): CacheStats;
/**
* Reset cache statistics
*/
resetStats(): void;
/**
* Get cache entries that match a pattern
*/
getByPattern(pattern: RegExp): Array<{
key: string;
value: any;
}>;
/**
* Set multiple values at once
*/
setMany<T = any>(entries: Array<{
key: string;
value: T;
ttl?: number;
}>): void;
/**
* Get multiple values at once
*/
getMany<T = any>(keys: string[]): Array<{
key: string;
value: T | null;
}>;
/**
* Delete multiple keys at once
*/
deleteMany(keys: string[]): number;
/**
* Get cache memory usage estimate (in bytes)
*/
getMemoryUsage(): number;
/**
* Cleanup expired entries
*/
cleanup(): number;
/**
* Destroy cache and cleanup resources
*/
destroy(): void;
/**
* Start automatic cleanup timer
*/
private startCleanupTimer;
/**
* Evict oldest entry when cache is full
*/
private evictOldest;
/**
* Update cache statistics
*/
private updateStats;
/**
* Update hit rate calculation
*/
private updateHitRate;
}
//# sourceMappingURL=ModuleCache.d.ts.map