#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

#473 in Concurrency

Download history 85/week @ 2024-03-30 39/week @ 2024-04-06 94/week @ 2024-04-13 133/week @ 2024-04-20 41/week @ 2024-04-27 12/week @ 2024-05-04 66/week @ 2024-05-11 102/week @ 2024-05-18 118/week @ 2024-05-25 58/week @ 2024-06-01 25/week @ 2024-06-08 28/week @ 2024-06-15 2/week @ 2024-06-22 63/week @ 2024-06-29 52/week @ 2024-07-06 45/week @ 2024-07-13

165 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

~3–4MB
~103K SLoC