#locking #redis #distributed #redlock #distributed-lock

redlock-async

Implementation of the distributed locking mechanism built on top of Async Redis

3 releases

0.0.3 Sep 9, 2022
0.0.2 Sep 9, 2022
0.0.1 Sep 9, 2022

#1803 in Database interfaces

Download history 33/week @ 2024-07-20 27/week @ 2024-07-27 26/week @ 2024-08-03 29/week @ 2024-08-10 35/week @ 2024-08-17 48/week @ 2024-08-24 33/week @ 2024-08-31 35/week @ 2024-09-07 9/week @ 2024-09-14 56/week @ 2024-09-21 51/week @ 2024-09-28 43/week @ 2024-10-05 65/week @ 2024-10-12 29/week @ 2024-10-19 37/week @ 2024-10-26 58/week @ 2024-11-02

206 downloads per month

BSD-3-Clause

17KB
328 lines

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.

Dependencies

~11–22MB
~324K SLoC