RadishDB is a Redis-inspired, in-memory key–value database written in C, built to understand how real databases work internally and how to deploy them like production services.
RadishDB implements real storage engine internals and is fully containerized and deployable using Docker and Docker Compose.
This project focuses on:
- write-ahead logging (WAL)
- crash recovery
- expiration & TTL
- log compaction
- persistent storage
- containerized deployment (Docker)
- service orchestration (docker-compose)
RadishDB is a learning-grade but architecturally serious database, following patterns used in Redis, RocksDB, and PostgreSQL.
- String → string mapping
- Hash table with separate chaining
- Automatic resizing
- Heap-managed memory
- Safe insert, update, delete
- Per-key expiration timestamps
- Passive expiration on read
- Active expiration via sweeper
- Redis-style TTL semantics
RadishDB uses two persistence layers.
Binary snapshot of full database state.
Used for fast save and restore.
Crash-safe write-ahead log.
Features:
- deterministic replay
- fsync durability
- partial write protection
- crash recovery
RadishDB implements log compaction:
- serializes current state
- writes new compact log
- removes obsolete history
This ensures:
- bounded disk usage
- fast startup
- crash safety
RadishDB is built as a protocol-agnostic execution engine.
engine.c → command semantics
hashtable.c → storage engine
aof.c → durability
expires.c → TTL system
persistence.c → snapshots
repl.c → interactive mode
server.c → TCP server
main.c → lifecycle
This separation allows multiple frontends:
- REPL
- TCP server
- container deployment
- future protocols
SET key value
SET key value EX seconds
GET key
DEL key
TTL key
COUNT
SAVE file
LOAD file
BENCH n
INFO
HELP
EXIT
SET name radish
OK
GET name
radish
SET color red EX 10
OK
TTL color
7
After restart:
GET name
radish
State recovered from AOF.
Build:
makeREPL mode:
./radishdbServer mode:
./radishdb --serverServer listens on port 6379.
RadishDB is published on Docker Hub.
Pull image:
docker pull piee314/radishdb:latestRun container:
docker run -d \
--name radishdb \
-p 6379:6379 \
-v radish-data:/app/aof \
piee314/radishdb:latestThis starts RadishDB with:
- persistent storage
- exposed network port
- isolated container runtime
RadishDB stores data in:
/app/aof/radish.aof
Docker volume ensures data persists across container restarts.
List volumes:
docker volume lsInspect volume:
docker volume inspect radish-datadocker-compose.yml:
version: "3.8"
services:
radishdb:
image: piee314/radishdb:latest
container_name: radishdb
ports:
- "6379:6379"
volumes:
- radish-data:/app/aof
restart: unless-stopped
volumes:
radish-data:Start service:
docker-compose up -dStop service:
docker-compose downView logs:
docker-compose logsRadishDB uses multi-stage Docker build:
build stage → compile binary
runtime stage → minimal Linux container
volume mount → persistent storage
Benefits:
- small image size
- fast startup
- production-ready deployment
RadishDB demonstrates real DevOps practices:
- Docker containerization
- multi-stage builds
- persistent volumes
- Docker Hub image publishing
- docker-compose orchestration
- reproducible deployments
RadishDB can run identically on:
- local machine
- cloud servers
- CI/CD pipelines
- container orchestration platforms
src/
├── engine.c
├── hashtable.c
├── aof.c
├── expires.c
├── persistence.c
├── repl.c
├── server.c
├── result.c
├── utils.c
Dockerfile
docker-compose.yml
Makefile
README.md
ARCHITECTURE.md
LEARNINGS.md
On any Linux server:
docker run -d \
-p 6379:6379 \
-v radish-data:/app/aof \
piee314/radishdb:latestRadishDB runs remotely and persists data.
Stable learning release.
Fully functional storage engine with persistent container deployment.
MIT License
Built as a systems engineering and DevOps learning project to understand:
- database internals
- crash recovery
- persistence
- containerization
- deployment workflows

