UNPKG

@varia-bly/variably-sdk

Version:

Official JavaScript/TypeScript SDK for Variably feature flags, experimentation, and real-time dynamic configurations

89 lines 2.14 kB
/** * Cache management for Variably SDK */ import { CacheConfig } from './types'; import { Logger } from './logger'; export declare class CacheManager { private cache; private config; private logger; private cleanupInterval; constructor(config: CacheConfig, logger: Logger); /** * Get a value from cache */ get<T = any>(key: string): T | null; /** * Set a value in cache */ set<T = any>(key: string, value: T, customTtl?: number): void; /** * Remove a value from cache */ delete(key: string): boolean; /** * Clear all cache entries */ clear(): void; /** * Clear cache entries matching a pattern (supports * wildcard) */ clearByPattern(pattern: string): number; /** * Get cache statistics */ getStats(): { size: number; maxSize: number; hitRate: number; enabled: boolean; }; /** * Check if cache entry has expired */ private isExpired; /** * Remove oldest entries when cache is full */ private evictOldest; /** * Remove expired entries from cache */ private cleanup; /** * Start periodic cleanup timer */ private startCleanupTimer; /** * Stop cleanup timer and clear cache */ destroy(): void; } /** * Simple in-memory cache for Node.js environments */ export declare class MemoryCache extends CacheManager { constructor(config: CacheConfig, logger: Logger); } /** * Browser-compatible cache using sessionStorage/localStorage */ export declare class BrowserCache { private config; private logger; private storage; private keyPrefix; constructor(config: CacheConfig, logger: Logger, useSessionStorage?: boolean); get<T = any>(key: string): T | null; set<T = any>(key: string, value: T, customTtl?: number): void; delete(key: string): boolean; clear(): void; getStats(): { size: number; maxSize: number; hitRate: number; enabled: boolean; }; destroy(): void; } //# sourceMappingURL=cache.d.ts.map