redlock

Crates.ioredlock
lib.rsredlock
version2.0.0
sourcesrc
created_at2015-04-09 19:25:38.746886
updated_at2023-04-06 21:45:40.688223
descriptionImplementation of the distributed locking mechanism built on top of Redis
homepagehttps://github.com/badboy/redlock-rs
repositoryhttps://github.com/badboy/redlock-rs
max_upload_size
id1826
size52,611
Aaron Griffin (aig787)

documentation

README

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.

Commit count: 60

cargo fmt