#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

#371 in Concurrency

Download history 19/week @ 2024-01-11 57/week @ 2024-01-18 90/week @ 2024-01-25 73/week @ 2024-02-01 37/week @ 2024-02-08 89/week @ 2024-02-15 130/week @ 2024-02-22 126/week @ 2024-02-29 72/week @ 2024-03-07 90/week @ 2024-03-14 70/week @ 2024-03-21 47/week @ 2024-03-28 76/week @ 2024-04-04 77/week @ 2024-04-11 124/week @ 2024-04-18 50/week @ 2024-04-25

339 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.5MB
~116K SLoC