Crates.io | redlock |
lib.rs | redlock |
version | 2.0.0 |
source | src |
created_at | 2015-04-09 19:25:38.746886 |
updated_at | 2023-04-06 21:45:40.688223 |
description | Implementation of the distributed locking mechanism built on top of Redis |
homepage | https://github.com/badboy/redlock-rs |
repository | https://github.com/badboy/redlock-rs |
max_upload_size | |
id | 1826 |
size | 52,611 |
This is an implementation of Redlock, the distributed locking mechanism built on top of Redis. It is more or less a port of the Ruby version.
It includes a sample application in main.rs.
cargo build --release
use redlock::RedLock;
fn main() {
let rl = RedLock::new(vec!["redis://127.0.0.1:6380/", "redis://127.0.0.1:6381/", "redis://127.0.0.1:6382/"]);
let lock;
loop {
match rl.lock("mutex".as_bytes(), 1000) {
Some(l) => { lock = l; break }
None => ()
}
}
// Critical section
rl.unlock(&lock);
}
Run tests with:
cargo test
Run sample application with:
cargo run --release
If you find bugs or want to help otherwise, please open an issue.
BSD. See LICENSE.