Crates.io | redislock |
lib.rs | redislock |
version | 1.3.0 |
source | src |
created_at | 2022-06-06 07:21:40.131742 |
updated_at | 2022-06-06 07:21:40.131742 |
description | Implementation of the distributed locking mechanism built on top of Redis |
homepage | https://github.com/hxuchen/redislock |
repository | https://github.com/hxuchen/redislock |
max_upload_size | |
id | 600520 |
size | 46,687 |
This is an implementation of Redislock, 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 redislock::{random_char, RedisLock};
fn main() {
let rl = RedisLock::new(vec![
"redis://127.0.0.1:6380/",
"redis://127.0.0.1:6381/",
"redis://127.0.0.1:6382/"]);
let lock;
loop {
let val = random_char(Some(20));
match rl.lock("mutex".as_bytes(), val, 1000, None, None) {
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.