@dbs-portal/core-api
Version:
HTTP client and API utilities for DBS Portal
99 lines • 2.29 kB
TypeScript
/**
* In-memory cache storage
*/
import type { CacheEntry } from '../types';
import type { CacheStorage } from './cache-manager';
/**
* In-memory cache storage implementation
*/
export declare class MemoryCache implements CacheStorage {
private cache;
/**
* Gets a cache entry
*/
get<T>(key: string): CacheEntry<T> | null;
/**
* Sets a cache entry
*/
set<T>(key: string, entry: CacheEntry<T>): void;
/**
* Deletes a cache entry
*/
delete(key: string): void;
/**
* Clears all cache entries
*/
clear(): void;
/**
* Gets the number of cached entries
*/
size(): number;
/**
* Gets all cache keys
*/
keys(): string[];
/**
* Gets all cache values
*/
values(): CacheEntry[];
/**
* Gets all cache entries
*/
entries(): Array<[string, CacheEntry]>;
/**
* Checks if a key exists in cache
*/
has(key: string): boolean;
/**
* Iterates over cache entries
*/
forEach(callback: (entry: CacheEntry, key: string) => void): void;
/**
* Gets cache statistics
*/
getStats(): {
size: number;
memoryUsage: number;
};
/**
* Estimates the size of an object in bytes
*/
private estimateObjectSize;
/**
* Cleans up expired entries
*/
cleanup(): number;
/**
* Gets entries sorted by timestamp (oldest first)
*/
getEntriesByAge(): Array<[string, CacheEntry]>;
/**
* Removes oldest entries to free up space
*/
evictOldest(count: number): string[];
/**
* Sets maximum cache size with LRU eviction
*/
setMaxSize(maxSize: number): void;
/**
* Gets cache hit ratio (requires tracking)
*/
getHitRatio(): number;
/**
* Exports cache data for serialization
*/
export(): Record<string, CacheEntry>;
/**
* Imports cache data from serialized format
*/
import(data: Record<string, CacheEntry>): void;
/**
* Creates a snapshot of current cache state
*/
snapshot(): Map<string, CacheEntry>;
/**
* Restores cache from a snapshot
*/
restore(snapshot: Map<string, CacheEntry>): void;
}
//# sourceMappingURL=memory-cache.d.ts.map