Zedis π
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.
Features
Redis Protocol Compatibility : Supports the Redis Serialization Protocol (RESP)locks
: Supports the Redis Serialization Protocol (RESP)locks Multiple Data Types : String and integer value storage with automatic type conversion
: String and integer value storage with automatic type conversion Core Commands : Essential Redis commands including GET, SET, INCR, DECR, DEL, EXISTS, and TYPE
: Essential Redis commands including GET, SET, INCR, DECR, DEL, EXISTS, and TYPE High Performance : Written in Zig for optimal performance and memory safety
: Written in Zig for optimal performance and memory safety Connection Management : Handles multiple concurrent client connections
: Handles multiple concurrent client connections Disk persistence (RDB) : Point-in-time snapshots of your dataset.
: Point-in-time snapshots of your dataset. Pub/Sub: Decoupled communication between services. (lastest feature)
Roadmap πΊοΈ
Add RDB snapshots
Add RDB snapshots Implement pub/sub functionality
Implement pub/sub functionality Implement AOF (Append Only File) logging
Implement AOF (Append Only File) logging Implement more Redis commands
Implement more Redis commands Add support for lists and sets
Add support for lists and sets Add configuration file support
Add configuration file support Implement key expiration
Implement key expiration Add clustering support
Add clustering support Performance benchmarking suite
Quick Start
Prerequisites
Zig (minimum version 0.15.1)
Building and Running
# 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.
Testing with Redis CLI
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
Development π οΈ
Project Structure
The codebase follows Zig conventions with clear separation of concerns:
Type-safe operations with compile-time guarantees
Explicit error handling throughout
Memory safety with RAII patterns
Comprehensive logging for debugging
Building for Development
# Build in debug mode (default) zig build -Doptimize=Debug # Build optimized release zig build -Doptimize=ReleaseFast # Run tests (when available) zig build test
Adding New Commands
Implement the command handler in the appropriate file under src/commands/ Register the command in the command registry Add tests for the new functionality
Example:
pub fn myCommand ( client : * Client , args : [] const Value ) ! void { // Command implementation try client . writeSimpleString ( "OK" ); }
Code Style
Follow Zig's standard formatting ( zig fmt )
) Add comprehensive error handling
Include documentation comments for public APIs
Write tests for new functionality
Contact π§
Zedis - Learning Redis internals through Zig! π¦β‘