import { StorageAdapter } from '../interfaces/storage-adapter.interface'; /** * In-memory storage adapter for development and single-server deployments * * CRITICAL LIMITATIONS FOR PRODUCTION: * - Data is lost on server restart * - Data is NOT shared across multiple server instances/containers * - Rate limiting may be bypassed in ECS/multi-container deployments * - NOT suitable for production clusters with multiple containers * * RECOMMENDATIONS: * - Single ECS task: Acceptable (data lost on restart) * - Multi-task/container ECS: Use the Redis adapter (@nauth-toolkit/storage-redis) * - Production: Use a shared storage adapter (Redis or database-backed) * * CURRENT BEHAVIOR: * Rate limiting works per-container, not globally across containers * * @example * ```typescript * const storage = new MemoryStorageAdapter(); * await storage.initialize(); * await storage.set('key', 'value', 60); // Set with 60 second TTL * const value = await storage.get('key'); * ``` */ export declare class MemoryStorageAdapter implements StorageAdapter { private store; private hashes; private lists; private cleanupInterval; /** * Initialize the storage adapter * Starts a background cleanup job to remove expired keys */ initialize(): Promise; /** * Check if the storage adapter is healthy and operational * @returns Always returns true for in-memory storage */ isHealthy(): Promise; /** * Get a value by key * Automatically removes and returns null if the key has expired * * @param key - The key to retrieve * @returns The stored value or null if not found/expired */ get(key: string): Promise; /** * Set a key-value pair with optional TTL (time to live) * * @param key - The key to store * @param value - The value to store * @param ttl - Time to live in seconds (optional) */ set(key: string, value: string, ttlSeconds?: number, options?: { nx?: boolean; }): Promise; /** * Delete a key from storage * @param key - The key to delete */ del(key: string): Promise; /** * Check if a key exists and is not expired * @param key - The key to check * @returns True if key exists and is valid, false otherwise */ exists(key: string): Promise; /** * Increment a counter stored at key * If the key doesn't exist, it's initialized to 0 before incrementing * Preserves TTL if the key already exists with an expiration * * @param key - The key to increment * @param ttlSeconds - Optional TTL in seconds to set when creating a new key (only applied if key doesn't exist) * @returns The new value after incrementing */ incr(key: string, ttlSeconds?: number): Promise; /** * Decrement a counter stored at key * If the key doesn't exist, it's initialized to 0 before decrementing * * @param key - The key to decrement * @returns The new value after decrementing */ decr(key: string): Promise; /** * Set expiration time on an existing key * @param key - The key to set expiration on * @param ttl - Time to live in seconds */ expire(key: string, ttl: number): Promise; /** * Get the time to live (TTL) for a key * @param key - The key to check * @returns Seconds until expiration, -1 if no expiration, -2 if key doesn't exist */ ttl(key: string): Promise; /** * Get a field value from a hash * @param key - Hash key * @param field - Field name * @returns Field value or null if not found */ hget(key: string, field: string): Promise; /** * Set a field value in a hash * @param key - Hash key * @param field - Field name * @param value - Field value */ hset(key: string, field: string, value: string): Promise; /** * Get all fields and values from a hash * @param key - Hash key * @returns Object with all field-value pairs */ hgetall(key: string): Promise>; /** * Delete one or more fields from a hash * @param key - Hash key * @param fields - Field names to delete * @returns Number of fields deleted */ hdel(key: string, ...fields: string[]): Promise; /** * Push value to the left (beginning) of a list * @param key - List key * @param value - Value to push */ lpush(key: string, value: string): Promise; /** * Get a range of elements from a list * @param key - List key * @param start - Start index (0-based) * @param stop - Stop index (-1 for end of list) * @returns Array of values in range */ lrange(key: string, start: number, stop: number): Promise; /** * Get the length of a list * @param key - List key * @returns List length */ llen(key: string): Promise; /** * Find all keys matching a pattern * @param pattern - Glob pattern (* and ? wildcards supported) * @returns Array of matching keys */ keys(pattern: string): Promise; /** * Iterate over keys matching a pattern (cursor-based) * @param cursor - Cursor position (0 to start) * @param pattern - Glob pattern * @param count - Number of keys to return * @returns Tuple of [new cursor, keys array] */ scan(cursor: number, pattern: string, count: number): Promise<[number, string[]]>; /** * Run cleanup of expired keys */ cleanup(): Promise; /** * Disconnect and cleanup all resources */ disconnect(): Promise; /** * Remove all expired keys from storage */ private cleanupExpired; /** * Convert a glob pattern to a regular expression * @param pattern - Glob pattern (* and ? wildcards) * @returns RegExp for pattern matching */ private patternToRegex; } //# sourceMappingURL=memory-storage.adapter.d.ts.map