/** * Society Protocol - Caching Layer * * LRU cache with TTL support for frequently accessed data. * Reduces database load and improves response times. */ import { EventEmitter } from 'events'; export interface CacheEntry { value: T; expiresAt: number; hits: number; } export interface CacheOptions { maxSize?: number; defaultTtlMs?: number; checkIntervalMs?: number; } /** * LRU Cache with TTL support */ export declare class LRUCache extends EventEmitter { private cache; private maxSize; private defaultTtlMs; private cleanupInterval?; private stats; constructor(options?: CacheOptions); /** * Get value from cache */ get(key: K): V | undefined; /** * Set value in cache */ set(key: K, value: V, ttlMs?: number): void; /** * Check if key exists and is not expired */ has(key: K): boolean; /** * Delete key from cache */ delete(key: K): boolean; /** * Clear all entries */ clear(): void; /** * Get all keys */ keys(): IterableIterator; /** * Get cache size */ get size(): number; /** * Get cache statistics */ getStats(): { size: number; maxSize: number; hitRate: number; hits: number; misses: number; evictions: number; expirations: number; }; /** * Reset statistics */ resetStats(): void; /** * Clean up expired entries */ private cleanup; /** * Destroy cache and stop cleanup interval */ destroy(): void; } /** * Knowledge-specific cache with space invalidation */ export declare class KnowledgeCache extends LRUCache { private spaceIndex; constructor(options?: CacheOptions); /** * Cache card with space tracking */ setCard(cardId: string, card: any, spaceId: string, ttlMs?: number): void; /** * Get cached card */ getCard(cardId: string): any | undefined; /** * Invalidate all cards in a space */ invalidateSpace(spaceId: string): number; /** * Cache space metadata */ setSpace(spaceId: string, space: any, ttlMs?: number): void; /** * Get cached space */ getSpace(spaceId: string): any | undefined; } /** * Federation cache with policy caching */ export declare class FederationCache extends LRUCache { constructor(options?: CacheOptions); /** * Cache federation */ setFederation(fedId: string, federation: any): void; /** * Get cached federation */ getFederation(fedId: string): any | undefined; /** * Cache policy check result */ setPolicyCheck(action: string, actor: string, result: any): void; /** * Get cached policy check */ getPolicyCheck(action: string, actor: string): any | undefined; } //# sourceMappingURL=cache.d.ts.map