build-redis-go

An in-memory Redis key-value server built from scratch using Go and raw TCP sockets.
Overview
build-redis-go is a systems programming project implementing an in-memory key-value store compatible with standard Redis clients (including redis-cli).
Rather than relying on third-party frameworks, it builds the networking layer directly on top of Go's net.Listener, parsing the binary Redis Serialization Protocol (RESP) from raw TCP streams.
Key Technical Highlights
- Concurrent TCP Server: Manages simultaneous client connections using lightweight goroutines and non-blocking I/O.
- RESP Protocol Parser: Complete deserialization and serialization of simple strings, errors, integers, bulk strings, and arrays.
- Thread-Safe In-Memory Store: Synchronized hash-map storage protected by
sync.RWMutexto guarantee safe concurrent reads and writes. - TTL Expiration Engine: Passive and active key expiration routines ensuring timely memory cleanup for keys with time-to-live bounds.
- Supported Commands: Full implementation of
PING,ECHO,SET(withPXmillisecond expiration),GET,CONFIG, and replication foundations.
Technology Stack
- Language: Go (Golang 1.22+)
- Networking: Standard library
netpackage with TCP sockets - Protocol: Redis Serialization Protocol (RESP v2)
- Concurrency: Goroutines, Channels, and
sync.RWMutex - Testing: Unit tests and automated integration testing against standard
redis-cli