A simplified, distributed key-value store built in Rust, implementing the Raft Consensus Protocol.
- Distributed Consensus: Uses Raft for leader election and log replication.
- Redis Compatible: Supports basic
SETandGETcommands via any standard Redis client. - In-Memory Storage: Fast, thread-safe storage using
DashMap. - Configurable: Easily specify node IDs, ports, and peer addresses via CLI.
- Rust (2024 edition)
cargo
git clone https://github.com/fzn0x/redix.git
cd redix
cargo build --releaseTo run as a single node, you must specify --peers-count 1 so the node can elect itself as leader:
cargo run -- --id 0 --peers-count 1 --raft-addr 127.0.0.1:8080 --redis-addr 127.0.0.1:6380Start each node in a separate terminal:
Node 0:
cargo run -- --id 0 --raft-addr 127.0.0.1:8000 --redis-addr 127.0.0.1:6379 --peer 1=127.0.0.1:8001 --peer 2=127.0.0.1:8002Node 1:
cargo run -- --id 1 --raft-addr 127.0.0.1:8001 --redis-addr 127.0.0.1:6380 --peer 0=127.0.0.1:8000 --peer 2=127.0.0.1:8002Node 2:
cargo run -- --id 2 --raft-addr 127.0.0.1:8002 --redis-addr 127.0.0.1:6381 --peer 0=127.0.0.1:8000 --peer 1=127.0.0.1:8001You can use the built-in interactive CLI or standard tools:
cargo run -- --id 0 --peers-count 1 --redis-addr 127.0.0.1:6380
cargo run --bin cli -- --addr 127.0.0.1:6380
# Inside the CLI:
redix> SET foo bar
redix> GET foo
redix> KEYS
redix> FLUSHALL
redix> DEL foocargo run --example basic_usagecd examples/nodejs
npm install
npm startRun the full test suite (including integration cluster tests):
cargo testThis project is licensed under the MIT License - see the LICENSE file for details.
