A from-scratch Redis server and interactive client CLI written in Go. Credits: Build Your Own Redis Challenge : CodeCrafters
| Binary | Path | Description |
|---|---|---|
redis-server |
app/ |
Full Redis server : RESP protocol, persistence, replication, pub/sub |
redis-cli |
cmd/redis-cli/ |
Rich interactive client : TUI REPL, autocomplete, live pub/sub feed |
# Default (port 6379)
go run ./app/
# Custom port
go run ./app/ --port 6380
# With RDB persistence
go run ./app/ --port 6379 --dir /tmp --dbfilename dump.rdb
# With AOF persistence
go run ./app/ --port 6379 --appendonly yes --appendfilename appendonly.aof
# As a replica
go run ./app/ --port 6380 --replicaof "127.0.0.1 6379"| Category | Commands |
|---|---|
| Basic | PING ECHO TYPE INFO |
| String | SET GET INCR DECR |
| List | LPUSH RPUSH LPOP RPOP LLEN LRANGE BLPOP |
| Stream | XADD XRANGE XREAD |
| Sorted set | ZADD ZRANGE ZRANK ZSCORE ZCARD ZREM |
| Geo | GEOADD GEOPOS GEODIST GEOSEARCH |
| Pub/Sub | SUBSCRIBE PSUBSCRIBE UNSUBSCRIBE PUNSUBSCRIBE PUBLISH |
| Transaction | MULTI EXEC DISCARD WATCH UNWATCH |
| Replication | REPLCONF PSYNC WAIT |
| ACL / Auth | AUTH ACL |
| Config / Keys | CONFIG KEYS |
Concurrency model: each client connection runs in its own goroutine; the store is protected by sync.RWMutex so reads run concurrently and writes are serialised โ similar to Redis but via OS threads instead of an event loop.
# Connect to local server
go run ./cmd/redis-cli/
# Custom host / port / password
go run ./cmd/redis-cli/ --host 127.0.0.1 --port 6380 --password secret
# Scripted demo (good for recording)
go run ./cmd/redis-cli/ --demo- Startup banner โ ASCII logo, connection status, ping latency, server version
- Autocomplete โ fuzzy command suggestions with synopsis, context-aware (suppressed during pub/sub)
- Typo correction โ Levenshtein distance hint when a command isn't recognised
- Color-coded output โ โ green for OK, โ red for errors, cyan integers, dim nil
- Sorted set tables โ
ZRANGE ... WITHSCORESrenders as an aligned member/score table - Stream cards โ
XRANGE/XREADrenders each entry with ID and field/value rows - GEO tables โ
GEOPOS/GEODISTrendered as labelled coordinate tables - Transaction mode โ prompt changes to
TXโบ(yellow), queued commands showโฌก QUEUED - Pub/Sub live feed โ Bubble Tea view with timestamped
๐messages,Ctrl+Cto exit and unsubscribe - Built-in help โ
HELPlists all commands by category;HELP <cmd>shows synopsis and example
# Build both binaries
go build -o redis-server ./app/
go build -o redis-cli ./cmd/redis-cli/
# Run all tests
go test ./...