A from-scratch, Redis-protocol-compatible key-value server written in Java and Spring. It speaks the real Redis wire protocol (RESP) over raw TCP sockets, and supports an in-memory store with expiry, transactions, and master–replica replication — plus a full Docker, CI, and Kubernetes deployment setup around it.
- RESP protocol — a hand-rolled encoder/decoder for Redis's actual wire format, not a borrowed library
- Core commands —
PING,ECHO,SET(with millisecond expiry viaPX),GET,INCR - Transactions —
MULTI/EXEC/DISCARD, applied atomically against the store - Replication — master/replica roles, a real
PSYNCfull-resync handshake, live command propagation,WAIT, and support for chained replicas - Containerized — multi-stage
Dockerfileproducing a small runtime image - CI/CD — an Azure Pipelines build/push pipeline with a self-hosted Docker-in-Docker agent
- Kubernetes-ready — a Helm chart, tested locally against a kind cluster
| Command | Notes |
|---|---|
PING |
|
ECHO <msg> |
|
SET <key> <value> [PX <ms>] |
optional expiry in milliseconds |
GET <key> |
|
INCR <key> |
|
MULTI / EXEC / DISCARD |
transactions |
INFO replication |
|
REPLCONF, PSYNC, WAIT |
replication internals |
Prerequisites: Java 23, Maven
./your_program.sh # build + start a master on port 6379
./your_program.sh --port 6380 --replicaof "localhost 6379" # start a replica of the aboveTry it with redis-cli:
redis-cli -p 6379 PING
redis-cli -p 6379 SET foo bar
redis-cli -p 6379 GET fooRun the test suite:
mvn testDOCUMENTATION.md is a full guided walkthrough of this codebase — architecture, the RESP protocol byte by byte, a component-by-component tour with diagrams, the concurrency model, design trade-offs, and an honest list of what's simplified compared to real Redis (including a couple of things confirmed by actually testing the server). It also has a set of interview-style questions and answers based on this project, and assumes little to no prior Java experience.
Docker
docker build -t redis-java .
docker run -p 6379:6379 redis-javaKubernetes (kind + Helm)
kind create cluster --config kind/k.yml --name cluster-name
docker build -t beelzekamibub/redis-java:latest .
kind load docker-image beelzekamibub/redis-java:latest --name cluster-name
helm install redis-app redis-chartCI (Azure Pipelines)
azure-pipelines.yml builds and pushes the Docker image on every push to master, running on a self-hosted agent (see dind/) rather than a hosted pool.
Full context and rationale for each of these lives in DOCUMENTATION.md.
This is a learning project, not a Redis replacement — a few things worth knowing before relying on it for anything real:
- A full resync always sends an empty snapshot; a replica only receives writes made after it connects, never the master's existing data
- Standalone
INCRhas a real, confirmed race condition under concurrent load - No persistence to disk — a restart loses everything
The complete list, with explanations, is in DOCUMENTATION.md.
src/main/java/
├── Main.java entry point
├── Config/ Spring wiring
└── Components/
├── Server/ RedisConfig, MasterTcpServer, SlaveTcpServer
├── Service/ RESP protocol codec, command dispatch
├── Repository/ the in-memory store
└── Infra/ connection/replica bookkeeping
See DOCUMENTATION.md for the fully annotated version of this tree.