How sawastik7-bit/build_your_own_redis_implementation works
This is a Redis-inspired TCP key-value server. Its principal workflow is a Redis CLI/client sending RESP over TCP; the server parses and dispatches commands, command handlers access the in-memory Map, and replies return over the socket. Supported command families include key operations, counters, expiration, multi-key access and server-side key management. Persistence uses a JSON dump, while a periodic expiration check is a separate internal layer. The graph follows documented or indexed relationships; some command implementations and the MSET/MGET handlers are not excerpted, so their detailed storage behavior is not asserted.
Main entry points: server.js TCP server and dispatcher · store.js In-memory Map · persistent.js JSON persistence · commands Key commands
Components 11
Network protocol
- TCP server and dispatcher
src/server.js - RESP parser
src/parser/respParser.js
Command handling
- Key commands
src/commands - Counter commands
src/commands - Expiration commands
src/commands - Multi-key commands
src/commands - Database commands
src/server.js
Storage and expiry
- In-memory Map
src/storage/store.js - JSON persistence
src/storage/persistent.js - Expiry checker
src/utils/expireCheckFunc.js
Other components
- Redis client
Connections 18
- Redis client → TCP server and dispatcher: sends TCP requests
README.md - TCP server and dispatcher → RESP parser: parses requests
src/server.js - TCP server and dispatcher → Key commands: dispatches key ops
src/server.js - TCP server and dispatcher → Counter commands: dispatches counters
src/server.js - TCP server and dispatcher → Expiration commands: dispatches expiry
src/server.js - TCP server and dispatcher → Multi-key commands: dispatches multi-key
src/server.js - TCP server and dispatcher → Database commands: handles DB ops
src/server.js - Key commands → In-memory Map: reads and writes
src/commands/set.js - Counter commands → In-memory Map: updates values
src/commands/incrFunc.js - Expiration commands → In-memory Map: reads and updates
src/commands/expireFunc.js - Key commands → JSON persistence: saves changes
src/commands/set.js - Counter commands → JSON persistence: saves changes
src/commands/incrFunc.js - Expiration commands → JSON persistence: saves changes
src/commands/expireFunc.js - In-memory Map → JSON persistence: loads at startup
src/storage/store.js - TCP server and dispatcher → Expiry checker: runs periodically
src/server.js - Expiry checker → In-memory Map: checks expirations
src/utils/expireCheckFunc.js - Expiry checker → JSON persistence: saves state
src/utils/expireCheckFunc.js - TCP server and dispatcher → Redis client: writes RESP replies
src/server.js