redlock/
lib.rs

1//! redlock-rs is an implementation of the [distributed locking
2//! mechanism](http://redis.io/topics/distlock) built on top of Redis.
3//!
4//! It is more or less a port of the [Ruby version](https://github.com/antirez/redlock-rb).
5//!
6//! # Basic Operation
7//! ```rust,no_run
8//! # use redlock::RedLock;
9//! let rl = RedLock::new(vec![
10//!     "redis://127.0.0.1:6380/",
11//!     "redis://127.0.0.1:6381/",
12//!     "redis://127.0.0.1:6382/"]);
13//!
14//! let lock;
15//! loop {
16//!   match rl.lock("mutex".as_bytes(), 1000) {
17//!     Ok(Some(l)) => { lock = l; break },
18//!     Ok(None) => (),
19//!     Err(e) => panic!("Error communicating with redis: {}", e)
20//!   }
21//! }
22//!
23//! // Critical section
24//!
25//! rl.unlock(&lock);
26//! ```
27
28mod redlock;
29
30pub use crate::redlock::{Lock, RedLock, RedLockGuard};