A Redis server implementation in Go, featuring RESP protocol support, in-memory data structures, and concurrent client handling.
- RESP (Redis Serialization Protocol) for client-server communication
- String, List, and Stream data types
- Thread-safe operations with goroutine-based connection handling
- Blocking list operations (BLPOP)
- TTL support with lazy deletion
- Graceful shutdown with structured logging (slog)
- Go 1.26+
- Task (optional, for task automation)
task run
# or
go run ./cmd/serverThe server starts on 0.0.0.0:6379 by default.
task build
# or
go build -o redis-server ./cmd/serverredis-cli -h localhost -p 6379PING— test connectivityECHO <message>— echo the given string
SET <key> <value> [EX seconds] [PX milliseconds]— set key with optional TTLGET <key>— get value by key
RPUSH <key> <value> [value ...]— append to the endLPUSH <key> <value> [value ...]— prepend to the startLRANGE <key> <start> <stop>— get range (supports negative indices)LLEN <key>— get lengthRPOP <key> [count]— remove and return from the endLPOP <key> [count]— remove and return from the startBLPOP <key> <timeout>— blocking pop from head
XADD <key> <ID> <field> <value> [field value ...]— add entry
TYPE <key>— get key type (string, list, stream, none)
cmd/server/ Entry point
internal/
commands/ Command handlers
config/ Server configuration
server/ TCP server and connection handling
store/ In-memory data store
pkg/
resp/ RESP protocol parser and encoder
task test # run tests with -race
task lint # run golangci-lint
task check # lint + test
task coverage # test with coverage report
task fmt # format codeThis project is open source and available for educational purposes.
Note: This is an educational Redis implementation. For production use, see Redis.