/** * Storage Tier Interface * Defines the contract for all storage tier implementations (RAM, SSD, DB) * Requirements: 2.1, 2.2, 2.3, 2.4 */ import { KeyMetadata } from '../types/index.js'; /** * Configuration options for initializing a storage tier */ export interface TierConfig { /** Maximum capacity in bytes for this tier */ capacityBytes: number; /** Optional path for persistent storage (SSD/DB tiers) */ storagePath?: string; /** Optional connection string for database tier */ connectionString?: string; } /** * StorageTier interface defines the contract for all storage tier implementations. * Each tier (RAM, SSD, DB) must implement this interface to provide consistent * access patterns across the tiered cache system. */ export interface StorageTier { /** * Retrieve a value by key * @param key - The cache key to retrieve * @returns The value as a Buffer, or null if not found */ get(key: string): Promise; /** * Store a key-value pair with metadata * @param key - The cache key * @param value - The value to store * @param metadata - Associated metadata (expiration, creation time, tier) */ set(key: string, value: Buffer, metadata: KeyMetadata): Promise; /** * Delete a key from the tier * @param key - The cache key to delete * @returns true if the key was deleted, false if it didn't exist */ delete(key: string): Promise; /** * Check if a key exists in this tier * @param key - The cache key to check * @returns true if the key exists, false otherwise */ exists(key: string): Promise; /** * Retrieve multiple values by keys (bulk operation) * @param keys - Array of cache keys to retrieve * @returns Map of key to value for keys that exist */ mget(keys: string[]): Promise>; /** * Store multiple key-value pairs (bulk operation) * @param entries - Map of key to value * @param metadata - Metadata to apply to all entries */ mset(entries: Map, metadata: KeyMetadata): Promise; /** * Get the current used bytes in this tier * @returns Number of bytes currently used */ getUsedBytes(): number; /** * Get the maximum capacity in bytes for this tier * @returns Maximum capacity in bytes */ getCapacityBytes(): number; /** * Iterate over keys in this tier, optionally filtered by pattern * @param pattern - Optional glob pattern to filter keys * @returns AsyncIterator yielding matching keys */ keys(pattern?: string): AsyncIterableIterator; /** * Initialize and open the storage tier * @param config - Configuration options for the tier */ open(config: TierConfig): Promise; /** * Close the storage tier and release resources */ close(): Promise; /** * Flush any pending writes to persistent storage */ flush(): Promise; } //# sourceMappingURL=StorageTier.d.ts.map