Crate redislock

Source
Expand description

redislock is an implementation of the distributed locking mechanism built on top of Redis.

It is more or less a port of the Ruby version.

§Basic Operation

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);

Structs§

Lock
RedisLock
The lock manager.

Functions§

random_char