barddoo/zedis
Redis in Zig
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.
Made for learning purposes. Not intended for production use.
Add RDB snapshots
Implement pub/sub functionality
Implement key expiration
Background job for key expiration
Add tests to key expiration
Implement AOF (Append Only File) logging
Implement more Redis commands
Add support for lists and sets
Add configuration file support
Add clustering support
Performance benchmarking suite
# Clone the repository
git clone https://github.com/barddoo/zedis.git
cd zedis
# Build the project
zig build
# Run the server
zig build run
The 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
string
The codebase follows Zig conventions with clear separation of concerns:
All memory allocations are handled during the initialization phase. No dynamic memory allocation occurs during command execution, ensuring high performance and predictability. Hugely inspired by this article.
# Build in debug mode (default)
zig build -Doptimize=Debug
# Build optimized release
zig build -Doptimize=ReleaseFast
# Run tests (when available)
zig build test
src/commands/
Example:
pub fn myCommand(client: *Client, args: []const Value) !void {
// Command implementation
try client.writeSimpleString("OK");
}
zig fmt
)