Crates.io | redlock-async |
lib.rs | redlock-async |
version | 0.0.3 |
source | src |
created_at | 2022-09-09 00:42:20.078068 |
updated_at | 2022-09-09 23:10:23.284456 |
description | Implementation of the distributed locking mechanism built on top of Async Redis |
homepage | https://github.com/rsecob/redlock-async-rs |
repository | https://github.com/rsecob/redlock-async-rs |
max_upload_size | |
id | 661398 |
size | 21,957 |
This is an implementation of Redlock, the distributed locking mechanism built on top of Redis.
It is a fork of existing redlock-rs with async built on top of it.
cargo build --release
use redlock::RedLock;
#[tokio::main]
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).await {
Ok(l) => { lock = l; break }
Err(_) => ()
}
}
// Critical section
rl.unlock(&lock).await;
}
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.