#redis #distributed-lock #redlock #distributed-systems

bin+lib redsync

A Rust implementation of Redlock for distributed locks with Redis

5 releases (2 stable)

1.0.1 Apr 18, 2023
1.0.0 Mar 1, 2021
0.1.2 Mar 1, 2021
0.1.1 Mar 1, 2021
0.1.0 Mar 1, 2021

#642 in Concurrency

Download history 40/week @ 2024-07-29 62/week @ 2024-08-05 111/week @ 2024-08-12 75/week @ 2024-08-19 46/week @ 2024-08-26 40/week @ 2024-09-02 8/week @ 2024-09-09 40/week @ 2024-09-16 192/week @ 2024-09-23 112/week @ 2024-09-30 49/week @ 2024-10-07 100/week @ 2024-10-14 141/week @ 2024-10-21 86/week @ 2024-10-28 80/week @ 2024-11-04 18/week @ 2024-11-11

326 downloads per month

MIT license

26KB
618 lines

crates.io docs.rs ci release

Redsync

A Rust implementation of Redlock for distributed locks with Redis.

Installation

Add the following line to your Cargo.toml file:

[dependencies]
redsync = "1.0.1"

Documentation

See https://docs.rs/redsync.

Quick Start

use std::error::Error;
use std::time::Duration;
use redsync::{RedisInstance, Redsync};

fn main() -> Result<(), Box<dyn Error>> {
  let dlm = Redsync::new(vec![
    RedisInstance::new("redis://127.0.0.1:6389")?,
    RedisInstance::new("redis://127.0.0.1:6399")?,
    RedisInstance::new("redis://127.0.0.1:6379")?,
  ]);

  let lock = dlm.lock("resource", Duration::from_secs(1))?;
  dlm.unlock(&lock)?;

  Ok(())
}

For more examples, see examples.

Dependencies

~4–5.5MB
~96K SLoC