How ph-tejas/redis-clone-cpp works
This is a Redis-inspired, multithreaded TCP in-memory database. A client command enters the server, is parsed and dispatched to a command implementation, then operates on shared storage; mutations can be persisted for replay after restart. The map also preserves the documented key/value, list, hash, expiration, and LRU capabilities. Several command implementations and persistence internals were not excerpted, so their detailed behavior and some connections are not asserted.
Main entry points: StorageEngine.cpp Shared storage · CommandFactory.cpp Command factory · RedisServer.cpp TCP server · CommandValidator.cpp Command validation
Components 15
Server runtime
- Runtime bootstrap
src/main.cpp - TCP server
src/server/RedisServer.cpp
Command dispatch
- Command parser
src/parser/CommandParser.cpp - Command handler
src/commands/CommandHandler.cpp - Command factory
src/commands/factory/CommandFactory.cpp - Command validation
src/validation/CommandValidator.cpp
Database commands
- Key-value commands
src/commands/types - List commands
src/commands/types - Hash commands
src/commands/types - Expiration commands
src/commands/types
Storage and recovery
- Shared storage
src/storage/StorageEngine.cpp - LRU eviction
src/cache/LRUCache.cpp - Persistence manager
src/persistence/PersistenceManager.cpp
Other components
- TCP client
- AOF file
Connections 22
- TCP client → TCP server: sends commands
- Runtime bootstrap → TCP server: starts
src/main.cpp - Runtime bootstrap → Shared storage: starts cleanup
src/main.cpp - TCP server → Command parser: parses input
- TCP server → Command handler: dispatches input
- Command parser → Command handler: provides tokens
- Command handler → Command factory: selects command
src/commands/CommandHandler.cpp - Command factory → Key-value 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 → Expiration commands: creates commands
src/commands/factory/CommandFactory.cpp - Key-value commands → Shared storage: operates on
src/commands/types/ExistsCommand.cpp - List commands → Shared storage: operates on
src/commands/types/LPUSHCommand.cpp - Hash commands → Shared storage: operates on
src/commands/types/HSETCommand.cpp - Expiration commands → Shared storage: operates on
src/commands/types/ExpireCommand.cpp - Key-value commands → Command validation: validates with
src/commands/types/ExistsCommand.cpp - List commands → Command validation: validates with
src/commands/types/LPUSHCommand.cpp - Hash commands → Command validation: validates with
src/commands/types/HSETCommand.cpp - Expiration commands → Command validation: validates with
src/commands/types/ExpireCommand.cpp - Shared storage → LRU eviction: updates eviction state
src/storage/StorageEngine.cpp - Shared storage → Persistence manager: replays and appends
src/storage/StorageEngine.cpp - Persistence manager → AOF file: reads and writes