How subayel-wali/redis_clone works
This is a Redis-inspired, multithreaded TCP in-memory database. Clients send textual commands to the server, which parses and dispatches them through command objects into shared storage; storage also handles expiration, LRU eviction, and append-only persistence/replay. The README documents networking and background expiration, while sampled source confirms storage, command construction, persistence calls, and the LRU cache. Some server dispatch and unsampled command implementations are represented only at the documented subsystem level.
Main entry points: StorageEngine.cpp Storage engine · CommandFactory.cpp Command factory · RedisServer.cpp Redis server · CommandValidator.cpp Command validation
Components 14
Client server
- Redis server
src/server/RedisServer.cpp
Command processing
- Command parser
src/parser/CommandParser.cpp - Command handler
src/commands/CommandHandler.cpp - Command factory
src/commands/factory/CommandFactory.cpp - KV commands
src/commands/types/SetCommand.cpp - List commands
src/commands/types/LPUSHCommand.cpp - Hash commands
src/commands/types/HSETCommand.cpp - TTL commands
src/commands/types/ExpireCommand.cpp - Command validation
src/validation/CommandValidator.cpp
Database state
- Storage engine
src/storage/StorageEngine.cpp - LRU eviction
src/cache/LRUCache.cpp - Expiry worker
src/main.cpp
Durability
- AOF persistence
src/persistence/PersistenceManager.cpp
Other components
- TCP client
Connections 20
- TCP client → Redis server: sends commands
- Redis server → Command parser: parses input
- Redis server → Command handler: dispatches input
- Command handler → Command factory: gets command
src/commands/CommandHandler.cpp - Command factory → KV commands: creates commands
src/commands/factory/CommandFactory.cpp - Command factory → List commands: creates commands
src/commands/factory/CommandFactory.cpp - Command factory → Hash commands: creates commands
src/commands/factory/CommandFactory.cpp - Command factory → TTL commands: creates commands
src/commands/factory/CommandFactory.cpp - KV commands → Command validation: validates input
- List commands → Command validation: validates input
src/commands/types/LPUSHCommand.cpp - Hash commands → Command validation: validates input
src/commands/types/HSETCommand.cpp - TTL commands → Command validation: validates input
src/commands/types/ExpireCommand.cpp - KV commands → Storage engine: executes operations
- List commands → Storage engine: executes operations
src/storage/StorageEngine.cpp - Hash commands → Storage engine: executes operations
src/commands/types/HSETCommand.cpp - TTL commands → Storage engine: executes operations
src/commands/types/ExpireCommand.cpp - Storage engine → LRU eviction: updates recency
src/storage/StorageEngine.cpp - Expiry worker → Storage engine: cleans expired keys
src/main.cpp - Storage engine → AOF persistence: appends and replays
src/storage/StorageEngine.cpp - Redis server → TCP client: sends replies