redis-go
Systems · Go · 2026 · Solo Builder
A Redis-compatible key-value server built from scratch in Go that speaks the real Redis protocol, so it works with redis-cli.
How it works
- redis-cli: The real Redis client
- TCP + RESP: The real Redis protocol, 17 commands
- Thread-safe store: With TTL key expiry
- AOF persistence: Crash recovery from the append-only file
One session, end to end
One real session, traced as you scroll: the demo recorded in the repo, from a cold start to a restart that keeps the data. Every command, reply and log line below is from that run.
Started with /tmp/redis-go-demo -addr :6380 -aof /tmp/redis-go-demo.aof: AOF loaded (0 commands · 13 µs), persistence enabled (appendfsync = everysec), ready to accept connections (addr = [::]:6380).
Commands: SET name sam → OK; GET name → "sam". Keys: name = "sam" (SET name sam); visits = 2 (INCR visits, twice); session = "abc" (SET with EX 60 · TTL 58 s).
Stopped: shutting down, then AOF flushed and closed. Restarted 7 s later; the AOF replayed 4 commands in 252 µs. After the restart: GET name → "sam" · GET visits → "2" · TTL session → 37.
Results
redis-benchmark against redis-go and Redis 8.10.3 on the same Apple M3 Pro, both on localhost with persistence off: SET, GET, INCR and MSET, 1,000,000 requests from 50 clients, without and with pipelining (16 commands per round trip).
- SET throughput vs Redis: 93% (167,280 vs 180,050 req/s)
- GET throughput vs Redis: 88% (167,140 vs 189,214 req/s)
- Pipelined GET req/s: 2.3M (104% of Redis's at 16 per round trip)
- Pipelined INCR vs Redis: 58% (Number parsing under one write lock)
Results vary by about ±10% between runs. Without pipelining the network round trip is the limit, not the server. Where redis-go beats Redis it is using about three cores (~310% CPU) to Redis's one, so per core Redis is more efficient.
Highlights
- Speaks the real Redis protocol (RESP), so it works with redis-cli; 17 commands implemented.
- Thread-safe store with TTL key expiry, and AOF persistence with crash recovery.
- About 90% of real Redis's throughput at 167k ops/sec, profiled with pprof.
- 59 tests run under the race detector in CI on GitHub Actions, with zero dependencies.
Stack
Go, TCP, Concurrency, RESP protocol, GitHub Actions