#distributed #locking

redlock

Implementation of the distributed locking mechanism built on top of Redis

5 releases (3 stable)

1.2.0 Aug 30, 2021
1.1.0 Apr 6, 2021
1.0.0 Jan 15, 2016
0.3.1 Nov 4, 2015
0.3.0 Apr 9, 2015

#70 in Concurrency

Download history 6/week @ 2021-07-03 12/week @ 2021-07-10 13/week @ 2021-07-17 24/week @ 2021-07-24 46/week @ 2021-07-31 11/week @ 2021-08-07 6/week @ 2021-08-14 11/week @ 2021-08-21 38/week @ 2021-08-28 8/week @ 2021-09-04 21/week @ 2021-09-11 244/week @ 2021-09-18 213/week @ 2021-09-25 238/week @ 2021-10-02 214/week @ 2021-10-09 314/week @ 2021-10-16

87 downloads per month

BSD-3-Clause

16KB
329 lines

redlock-rs - Distributed locks with Redis

GitHub Workflow Status Crates.io

This is an implementation of Redlock, 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.

Build

cargo build --release

Usage

use redlock::RedLock;

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) {
      Some(l) => { lock = l; break }
      None => ()
    }
  }

  // Critical section

  rl.unlock(&lock);
}

Tests

Run tests with:

cargo test

Run sample application with:

cargo run --release

Contribute

If you find bugs or want to help otherwise, please open an issue.

Maintainer

  • From 2014 to June 2021 this crate was owned and maintained by @badboy
  • From June 2021 on this crate is maintained by @aig787

License

BSD. See LICENSE.

Dependencies

~3–5MB
~116K SLoC

@,a