UNPKG

sec-edgar-toolkit

Version:

Open source toolkit to facilitate working with the SEC EDGAR database

129 lines 3.09 kB
/** * Comprehensive caching system for SEC EDGAR data */ export interface CacheEntry<T> { data: T; timestamp: number; expiry?: number; } export interface CacheOptions { ttl?: number; maxSize?: number; persistent?: boolean; } export interface CacheStats { size: number; hits: number; misses: number; hitRate: number; } export declare class Cache<T = any> { private cache; private options; private accessOrder; private hits; private misses; constructor(options?: CacheOptions); /** * Get an item from cache */ get(key: string): T | null; /** * Set an item in cache */ set(key: string, data: T, ttl?: number): void; /** * Delete an item from cache */ delete(key: string): boolean; /** * Clear all cache entries */ clear(): void; /** * Check if key exists in cache */ has(key: string): boolean; /** * Get cache size */ get size(): number; /** * Get all keys */ keys(): string[]; /** * Get cache statistics */ getStats(): CacheStats; /** * Invalidate entries matching a pattern */ invalidatePattern(pattern: RegExp): number; /** * Clean up expired entries */ cleanup(): number; /** * Generate cache key from multiple values */ static generateKey(...values: any[]): string; /** * Update access order for LRU eviction */ private updateAccessOrder; /** * Remove key from access order */ private removeFromAccessOrder; /** * Evict least recently used item */ private evictLRU; } /** * Decorator for caching method results */ export declare function cacheable(options?: CacheOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Multi-level cache supporting memory and persistent storage */ export declare class MultiLevelCache<T = any> { private memoryCache; private persistentCache?; constructor(options?: CacheOptions); get(key: string): Promise<T | null>; set(key: string, data: T, ttl?: number): Promise<void>; delete(key: string): Promise<boolean>; clear(): Promise<void>; } /** * Request cache specifically for HTTP responses */ export declare class RequestCache { private cache; constructor(options?: CacheOptions); /** * Generate cache key for HTTP request */ private generateRequestKey; /** * Get cached response */ get(url: string, options?: any): Promise<any | null>; /** * Cache response */ set(url: string, response: any, options?: any, ttl?: number): Promise<void>; /** * Delete cached response */ delete(url: string, options?: any): Promise<boolean>; /** * Invalidate all cache entries for a base URL */ invalidateUrl(_baseUrl: string): Promise<void>; } export declare const globalCache: Cache<any>; export declare const requestCache: RequestCache; //# sourceMappingURL=cache.d.ts.map