UNPKG

@dbs-portal/core-api

Version:

HTTP client and API utilities for DBS Portal

80 lines 2.02 kB
/** * Cache manager for API responses */ import type { CacheConfig, RequestConfig, ApiResponse, CacheEntry } from '../types'; /** * Interface for cache storage */ export interface CacheStorage { get<T>(key: string): Promise<CacheEntry<T> | null> | CacheEntry<T> | null; set<T>(key: string, entry: CacheEntry<T>): Promise<void> | void; delete(key: string): Promise<void> | void; clear(): Promise<void> | void; size(): Promise<number> | number; keys(): Promise<string[]> | string[]; } /** * Cache manager for API responses */ export declare class CacheManager { private storage; private config; constructor(config: CacheConfig); /** * Gets a cached response */ get<T>(config: RequestConfig): Promise<ApiResponse<T> | null>; /** * Sets a response in cache */ set<T>(config: RequestConfig, response: ApiResponse<T>): Promise<void>; /** * Deletes a cached entry */ delete(config: RequestConfig): Promise<void>; /** * Clears all cached entries */ clear(): Promise<void>; /** * Invalidates cache entries based on pattern */ invalidate(pattern: string | RegExp): Promise<void>; /** * Gets cache statistics */ getStats(): Promise<{ size: number; maxSize: number; hitRate: number; missRate: number; totalRequests: number; hits: number; misses: number; }>; /** * Updates cache configuration */ updateConfig(config: Partial<CacheConfig>): void; /** * Cleans up expired entries */ cleanup(): Promise<number>; /** * Generates cache key for request */ private generateKey; /** * Checks if cache entry has expired */ private isExpired; /** * Enforces maximum cache size */ private enforceMaxSize; /** * Creates storage instance based on configuration */ private createStorage; } //# sourceMappingURL=cache-manager.d.ts.map