redlock-async

Crates.ioredlock-async
lib.rsredlock-async
version0.0.3
sourcesrc
created_at2022-09-09 00:42:20.078068
updated_at2022-09-09 23:10:23.284456
descriptionImplementation of the distributed locking mechanism built on top of Async Redis
homepagehttps://github.com/rsecob/redlock-async-rs
repositoryhttps://github.com/rsecob/redlock-async-rs
max_upload_size
id661398
size21,957
Romain Boces (rsecob)

documentation

README

redlock-async-rs - Async 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 a fork of existing redlock-rs with async built on top of it.

Build

cargo build --release

Usage

use redlock::RedLock;

#[tokio::main]
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).await {
      Ok(l) => { lock = l; break }
      Err(_) => ()
    }
  }

  // Critical section
  rl.unlock(&lock).await;
}

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.

License

BSD. See LICENSE.

Commit count: 55

cargo fmt