/** * Command Router Implementation * Routes Redis commands to appropriate CacheEngine methods * Requirements: 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, 1.12 */ import { CacheEngine } from '../cache/CacheEngine.js'; import { ListOperations } from '../cache/ListOperations.js'; import { HashOperations } from '../cache/HashOperations.js'; import { SetOperations } from '../cache/SetOperations.js'; /** * CommandRouter routes Redis commands to the appropriate handler methods. * It takes dependencies on CacheEngine and data structure operations classes. * * Requirements: * - 1.1: Support GET command * - 1.2: Support SET command with optional TTL * - 1.3: Support DEL command * - 1.4: Support MGET command * - 1.5: Support MSET command * - 1.6: Support EXISTS command * - 1.7: Support EXPIRE command * - 1.8: Support TTL command * - 1.9: Support INCR and DECR commands * - 1.10: Support list commands (LPUSH, RPUSH, LPOP, RPOP, LRANGE) * - 1.11: Support hash commands (HSET, HGET, HMSET, HMGET, HGETALL) * - 1.12: Support set commands (SADD, SREM, SMEMBERS, SISMEMBER) */ export declare class CommandRouter { private readonly cacheEngine; private readonly listOps; private readonly hashOps; private readonly setOps; private readonly serializer; constructor(cacheEngine: CacheEngine, listOps: ListOperations, hashOps: HashOperations, setOps: SetOperations); /** * Handle a Redis command and return the RESP-formatted response. * * @param command - Array of command parts (command name + arguments) * @returns Buffer containing RESP-formatted response */ handleCommand(command: string[]): Promise; /** * Handle PING command * @returns PONG response */ private handlePing; /** * Handle GET command * GET key → return bulk string or null * * Requirement 1.1: Support GET command */ private handleGet; /** * Handle SET command * SET key value [EX seconds] [NX|XX] → return OK * * Requirement 1.2: Support SET command with optional TTL */ private handleSet; /** * Handle DEL command * DEL key [key ...] → return integer (count deleted) * * Requirement 1.3: Support DEL command */ private handleDel; /** * Handle EXISTS command * EXISTS key [key ...] → return integer (count existing) * * Requirement 1.6: Support EXISTS command */ private handleExists; /** * Handle EXPIRE command * EXPIRE key seconds → return integer (1 if set, 0 if key not found) * * Requirement 1.7: Support EXPIRE command */ private handleExpire; /** * Handle TTL command * TTL key → return integer (seconds remaining, -1 no expiry, -2 not found) * * Requirement 1.8: Support TTL command */ private handleTtl; /** * Handle MGET command * MGET key [key ...] → return array of bulk strings * * Requirement 1.4: Support MGET command */ private handleMget; /** * Handle MSET command * MSET key value [key value ...] → return OK * * Requirement 1.5: Support MSET command */ private handleMset; /** * Handle INCR command * INCR key → return integer (new value) * * Requirement 1.9: Support INCR command */ private handleIncr; /** * Handle DECR command * DECR key → return integer (new value) * * Requirement 1.9: Support DECR command */ private handleDecr; /** * Handle LPUSH command * LPUSH key value [value ...] → return integer (list length) * * Requirement 1.10: Support LPUSH command */ private handleLpush; /** * Handle RPUSH command * RPUSH key value [value ...] → return integer (list length) * * Requirement 1.10: Support RPUSH command */ private handleRpush; /** * Handle LPOP command * LPOP key → return bulk string or null * * Requirement 1.10: Support LPOP command */ private handleLpop; /** * Handle RPOP command * RPOP key → return bulk string or null * * Requirement 1.10: Support RPOP command */ private handleRpop; /** * Handle LRANGE command * LRANGE key start stop → return array * * Requirement 1.10: Support LRANGE command */ private handleLrange; /** * Handle HSET command * HSET key field value → return integer (1 new, 0 updated) * * Requirement 1.11: Support HSET command */ private handleHset; /** * Handle HGET command * HGET key field → return bulk string or null * * Requirement 1.11: Support HGET command */ private handleHget; /** * Handle HMSET command * HMSET key field value [field value ...] → return OK * * Requirement 1.11: Support HMSET command */ private handleHmset; /** * Handle HMGET command * HMGET key field [field ...] → return array * * Requirement 1.11: Support HMGET command */ private handleHmget; /** * Handle HGETALL command * HGETALL key → return array (alternating field/value) * * Requirement 1.11: Support HGETALL command */ private handleHgetall; /** * Handle SADD command * SADD key member [member ...] → return integer (count added) * * Requirement 1.12: Support SADD command */ private handleSadd; /** * Handle SREM command * SREM key member [member ...] → return integer (count removed) * * Requirement 1.12: Support SREM command */ private handleSrem; /** * Handle SMEMBERS command * SMEMBERS key → return array * * Requirement 1.12: Support SMEMBERS command */ private handleSmembers; /** * Handle SISMEMBER command * SISMEMBER key member → return integer (1 or 0) * * Requirement 1.12: Support SISMEMBER command */ private handleSismember; } //# sourceMappingURL=CommandRouter.d.ts.map