Crates.io | rust_redlock |
lib.rs | rust_redlock |
version | 0.4.0 |
source | src |
created_at | 2017-05-18 14:36:10.342568 |
updated_at | 2017-08-02 14:52:22.704919 |
description | A Rust Redlock implementation for distributed, highly-available redis locks |
homepage | https://github.com/DavidCai1993/redlock-rs |
repository | https://github.com/DavidCai1993/redlock-rs |
max_upload_size | |
id | 15043 |
size | 18,802 |
A Rust Redlock implementation for distributed, highly-available redis locks.
[dependencies]
rust_redlock = "0.4.0"
See: https://docs.rs/rust_redlock/0.4.0/rust_redlock
let redlock = Redlock::new(Config {
addrs: vec!["redis1.example.com",
"redis2.example.com",
"redis3.example.com"],
retry_count: 10,
retry_delay: time::Duration::from_millis(400),
retry_jitter: 400,
drift_factor: 0.01,
})?;
// Acquire the lock of the specified resource.
let lock = redlock.lock("resource_name",
time::Duration::from_millis(1000))?;
// Release the lock of the resource when you are done.
lock.unlock()?;