Crates.io | redis-lock |
lib.rs | redis-lock |
version | 0.5.1 |
source | src |
created_at | 2024-10-22 16:11:02.308022 |
updated_at | 2024-11-24 14:26:28.88631 |
description | Rusty distributed locking backed by Redis. |
homepage | |
repository | https://github.com/JonathanWoollett-Light/redis-lock |
max_upload_size | |
id | 1418889 |
size | 82,356 |
Rusty distributed locking backed by Redis.
// Setup.
redis_lock::setup(&client).await?;
// Get lock.
let mut lock = redis_lock::MultiResourceLock::new(client.clone())?;
let resources = vec![String::from("account1"), String::from("account2")];
// Execute a function with the lock.
lock.map_default(&resources, async move { /* .. */ }).await?;
I would recommend this library over rslock when your application does operations that require exclusive access to multiple resources.