How dhravya/radish works
Project type and purpose
• Radish is a single-process, in-memory key-value store (a Redis replacement) written in Go. It listens over TCP (and RESP protocol), parses commands, executes them against in-memory data structures, implements persistence and pub/sub, and speaks the Redis protocol.
Key components (from file tree + README)
• Entry point: main.go
• Protocol handling: redisproto/ (parser.go, writer.go, fmt.go)
• Command dispatch & handlers: utils.go, persistence.go, pubsub.go, transactions.go (plus any command-specific code in utils or dedicated files)
• In-memory datastore: maps, slices, sorted sets, hashes, etc. (implemented throughout utils.go & go files)
• Persistence engine: persistence.go (SAVE, BGSAVE)
• Pub/Sub engine: pubsub.go
• Transaction manager: transactions.go (MULTI/EXEC/DISCARD)
• External interfaces: Dockerfile, CLI binaries in bin/
• Tests: tests/*.py and redisproto/parser_test.go
High-level architecture & interactions
• Clients (redis-cli, any RESP client) connect over TCP to the Radish server.
• The server’s TCP listener (main.go) hands raw RESP frames to the redisproto parser.
• Parsed commands are routed by a command dispatcher (in main.go or utils.go) to the appropriate handler module (strings, lists, sets, hashes, sorted-sets, keys, transactions, pub/sub, persistence).
• Handlers manipulate in-memory data structures (primary data store).
• Persistence manager listens for SAVE/BGSAVE commands and snapshots/flushing data to disk (AOF/RDB logic in persistence.go).
• Pub/Sub manager tracks channels and subscriber lists; PUBLISH calls fan-out messages to subscribers.
• Transaction manager queues commands in a MULTI block and executes atomically on EXEC.
• The response writer (redisproto/writer.go) formats replies into RESP and pushes them back over the TCP connection.