A Redis-compatible in-memory data store written in Zig, designed for learning and experimentation. Zedis implements the core Redis protocol and data structures with a focus on simplicity, performance, and thread safety.
Not intended for production use yet.
- Redis Protocol Compatibility: Supports the Redis Serialization Protocol (RESP), including pipelined commands.
- Multiple Data Types: Strings and integers, lists, time series, and Bloom filters.
- Core Commands: Key management (
DEL,EXISTS,TYPE,TTL,EXPIRE,KEYS), strings, lists (LPUSH/RPUSH/LRANGE, ...), andRANDOMKEY. - High Performance: Written in Zig, with a single-executor command path and no global store lock.
- Key Expiration: Lazy TTL expiry on access, plus expiry checks during eviction.
- Disk persistence (RDB): Point-in-time snapshots of your dataset.
- Append-only file (AOF): Durable write-ahead logging with group commit.
- Memory Budgeting: Redis-compatible
maxmemorywith eviction,-OOMrejection for allocating commands, and cgroup-aware auto-sizing inside containers. - Pub/Sub: Decoupled communication between services, with push delivery to idle subscribers.
- Time Series: Time series data structure. Now with Gorilla compression!
- Opinionated Design: No multiple logical databases, expiry is lazy only.
- Zedis is intentionally single-store. It does not support multiple logical databases and does not expose Redis
SELECT. It adds complexity and segment memory. This follows the reasoning Salvatore Sanfilippo gave when he called Redis multiple databases one of his worst design decisions.
Download the binary from the releases page or build from source to get started with Zedis.
- Zig 0.17.0 (pinned in
build.zig.zon)
# Clone the repository
git clone https://github.com/barddoo/zedis.git
cd zedis
# Build the project (optimized, ReleaseFast)
zig build --release=fast
# Run the server
zig build run --release=fastThe server will start on 127.0.0.1:6379 by default.
You can test Zedis using the standard redis-cli or any Redis client:
# Connect to Zedis
redis-cli -h 127.0.0.1 -p 6379
# Try some commands
127.0.0.1:6379> SET mykey "Hello, Zedis!"
OK
127.0.0.1:6379> GET mykey
"Hello, Zedis!"
127.0.0.1:6379> INCR counter
(integer) 1
127.0.0.1:6379> TYPE mykey
stringPre-built images are available on Docker Hub:
docker run -p 6379:6379 barddoo/zedis| Tag | Base | Notes | Use case |
|---|---|---|---|
latest, x.x.x, x.x.x-debian, x.x.x-slim |
Debian Trixie slim | Larger, glibc base | Default; broader ecosystem |
x.x.x-alpine, alpine |
Alpine 3.20 | Smallest with shell | Size-sensitive deployments |
x.x.x-distroless |
Distroless static | No shell | Security-sensitive |
Mount a volume to persist data across restarts:
docker run -p 6379:6379 -v zedis-data:/var/lib/zedis/data barddoo/zedisdocker run -p 6379:6379 -v ./zedis.conf:/etc/zedis/zedis.conf barddoo/zedisThe codebase is split by responsibility:
src/app/— server lifecycle, client connections, config, clocksrc/storage/— store, KV allocator, lists, time series, Bloom filters, searchsrc/commands/— command handlers and registrysrc/persistence/— AOF and RDBsrc/protocol/— RESP parser and serializersrc/util/— mailbox, stack writer, types, compressionsrc/benchmarks/— micro/load benchmarks
See docs/server-architecture.md for the current server thread model and request flow.
See docs/memory-architecture.md for the current allocator layout, memory budgets, and runtime allocation behavior. See docs/store-cache-layout.md for the store's hash-table layout and cache behavior.
# Build in debug mode (default)
zig build
# Build optimized release (ReleaseFast; use this for benchmarks and performance testing)
zig build --release=fast
# `--release` with no mode also picks ReleaseFast (the preferred mode in build.zig)
zig build --release
# Run the full test suite
zig build test
# Run a focused subset
zig build test -Dtest-filter="Store"
# Format the source
zig fmt .This project was developed with some AI help. Most of the code was written by hand.
Contributors are welcome! Whether you're fixing bugs, adding features, improving documentation, or suggesting enhancements, your contributions are appreciated.
Feel free to:
- Open an issue to report bugs or suggest features
- Submit pull requests with improvements
- Share feedback and ideas
Check out the open issues to see where you can help.
- Subscribe to my newsletter
- Andrew Kelley - For creating the amazing Zig Language.
- Redis - For the inspiration and protocol design.
- TigerBeetle - For the memory management and the tiger style.
- Karl Seguin - For the great articles.