/** * Cache Invalidation System * * Tag-based cache invalidation for maintaining consistency. * When data changes, invalidate all related cache entries by tag. */ import type { CacheService } from './cache-adapter.js'; /** * Cache tags for organizing related entries */ export declare enum CacheTag { VAULT = "vault", PORTFOLIO = "portfolio", TRANSACTION = "transaction", ANALYTICS = "analytics", APR = "apr", RISK = "risk", ALL = "all" } /** * Cache invalidation coordinator */ export declare class CacheInvalidator { private cache; private tagMap; constructor(cache: CacheService); /** * Register a cache key with its associated tags. * Also prunes stale entries (keys expired from cache but still in tagMap). */ register(key: string, tags: CacheTag[]): void; /** * Remove tagMap entries for keys that no longer exist in the cache. * Prevents unbounded tagMap growth from TTL-expired entries. */ pruneExpired(): void; /** * Invalidate all cache entries with the given tag */ invalidateByTag(tag: CacheTag): number; /** * Invalidate multiple tags at once */ invalidateByTags(tags: CacheTag[]): number; /** * Invalidate a specific cache key */ invalidateKey(key: string): boolean; /** * Clear all cache entries */ invalidateAll(): void; /** * Get all keys associated with a tag */ getKeysByTag(tag: CacheTag): string[]; /** * Get cache statistics with tag information */ getStats(): { totalKeys: number; tagCount: number; keysByTag: Record; }; } /** * Example usage relationships * * When vault data changes: * - Invalidate CacheTag.VAULT → clears vault data, apr, risk analysis * * When portfolio is rebalanced: * - Invalidate CacheTag.PORTFOLIO → clears portfolio optimization * * When transaction occurs: * - Invalidate [CacheTag.VAULT, CacheTag.ANALYTICS] → clears affected data */ //# sourceMappingURL=cache-invalidation.d.ts.map