Skip to content

Rust implementation of Redlock for distributed locks with Redis

License

Notifications You must be signed in to change notification settings

jace-ys/redsync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Rust implementation of Redlock for distributed locks with Redis

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages