/** * Memory Storage Adapter * * In-memory storage implementation for development and testing. * Supports TTL, pattern matching, pub/sub via EventEmitter. */ import { BaseStorageAdapter } from './base'; import type { MemoryAdapterOptions, SetOptions, MessageHandler, Unsubscribe } from '../types'; /** * In-memory storage adapter. * * Features: * - TTL support with lazy expiration + optional background sweeper * - Pattern matching for keys() with ReDoS protection * - Pub/sub via EventEmitter * - Optional LRU eviction * * @example * ```typescript * const adapter = new MemoryStorageAdapter({ * enableSweeper: true, * sweepIntervalSeconds: 60, * }); * * await adapter.connect(); * await adapter.set('key', 'value', { ttlSeconds: 300 }); * const value = await adapter.get('key'); * await adapter.disconnect(); * ``` */ export declare class MemoryStorageAdapter extends BaseStorageAdapter { protected readonly backendName = "memory"; private readonly store; private readonly emitter; private sweepInterval?; private readonly options; private accessOrder; constructor(options?: MemoryAdapterOptions); connect(): Promise; disconnect(): Promise; ping(): Promise; get(key: string): Promise; protected doSet(key: string, value: string, options?: SetOptions): Promise; delete(key: string): Promise; exists(key: string): Promise; expire(key: string, ttlSeconds: number): Promise; ttl(key: string): Promise; keys(pattern?: string): Promise; incr(key: string): Promise; decr(key: string): Promise; incrBy(key: string, amount: number): Promise; supportsPubSub(): boolean; publish(channel: string, message: string): Promise; subscribe(channel: string, handler: MessageHandler): Promise; /** * Delete an entry and clear its timeout. */ private deleteEntry; /** * Clear timeout for an entry. */ private clearEntryTimeout; /** * Clear all timeouts. */ private clearAllTimeouts; /** * Update LRU access order. */ private touchLRU; /** * Remove key from LRU tracking. */ private removeLRU; /** * Evict oldest entry (LRU). */ private evictOldest; /** * Start background sweeper. */ private startSweeper; /** * Stop background sweeper. */ private stopSweeper; /** * Sweep expired entries. */ private sweep; /** * Get storage statistics. */ getStats(): { size: number; maxEntries: number; sweeperActive: boolean; }; }