A distributed in-memory cache system built in Go.
The project implements:
- Redis-compatible protocol for seamless client integration
- Distributed caching with consistent hashing
- Master-slave replication for high availability
- Memory-efficient cache engine with TTL support
- Thread-safe concurrent operations
- TTL-based key expiration
- Basic Redis commands (GET, SET, DEL, etc.)
- Configurable cache size and eviction policies
- Consistent hashing for data distribution
- Master-slave replication
- Automatic node discovery
- Cluster management and health checks
- Language: Go 1.21+
- Testing: Built-in Go testing framework with testify
- Protocol: Redis RESP protocol
- Architecture: Distributed systems, microservices
# Clone the repository
git clone https://github.com/Nadeerpk/zephyr.git
cd zephyr
# Run tests
go test ./...
# Build the binary
go build -o zephyr cmd/main.go
# Start a single node
./zephyr --port 6379
# Start a cluster master node
./zephyr --port 7009 --role master --seeds 127.0.0.1:7002 --slaves 127.0.0.1:7003
# Start a cluster slave node
./zephyr --port 7003 --role slave --master 127.0.0.1:7009 --slaves 127.0.0.1:7003
# Start a cluster seed node
./zephyr --port 7002 --role master
import "github.com/go-redis/redis/v8"
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})
// Set a key with TTL
client.Set(ctx, "mykey", "myvalue", time.Minute)
// Get a key
val, err := client.Get(ctx, "mykey").Result().
├── cmd/
│ └── main.go # Application entry point
├── internal/
│ ├── cache/ # Core cache implementation
│ ├── cluster/ # Clustering logic
│ ├── consistent/ # Consistent hashing
│ ├── protocol/ # RESP protocol parser
│ ├── replication/ # Master-slave replication
│ └── server/ # TCP server implementation
└── tests/ # Integration tests
- Add persistence layer
- Implement more Redis commands
- Add metrics and monitoring
- Improve cluster management
- Add authentication and TLS support
This project is licensed under the MIT License - see the LICENSE file for details.