Expand description
§Installation
Add the following line to your Cargo.toml file:
[dependencies]
redsync = "1.0.1"§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.
Structs§
- Lock
Lockholds the metadata of an acquired lock.- Multi
Error MultiErrorwrapsVec<RedsyncError>, typically aggregated over instances in a Redsync cluster.- Redis
Instance RedisInstanceis the implementation of the Instance trait for a Redis server.- Redsync
Redsyncis a distributed lock manager that implements the Redlock algorithm.- Redsync
Builder RedsyncBuilderis a builder for configuring and constructing a Redsync instance.
Enums§
- Redsync
Error RedsyncErroris an enum of all error kinds returned by the crate.
Traits§
- Instance
Instancerepresents an entity with locking and unlocking capabilities.