Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 916 Bytes

README.md

File metadata and controls

35 lines (27 loc) · 916 Bytes

redlock-rs

Build Status

A Rust Redlock implementation for distributed, highly-available redis locks.

Installation

[dependencies]
rust_redlock = "0.4.0"

Documentation

See: https://docs.rs/rust_redlock/0.4.0/rust_redlock

Usage

let redlock = Redlock::new(Config {
    addrs: vec!["redis1.example.com",
                "redis2.example.com",
                "redis3.example.com"],
    retry_count: 10,
    retry_delay: time::Duration::from_millis(400),
    retry_jitter: 400,
    drift_factor: 0.01,
})?;

// Acquire the lock of the specified resource.
let lock = redlock.lock("resource_name",
                        time::Duration::from_millis(1000))?;
// Release the lock of the resource when you are done.
lock.unlock()?;