Expand description
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?;
§Vs rslock
I would recommend this library over rslock when:
- your application is focussed on
async
. - your application does operations that require exclusive access to multiple resources.
§Similar work
Modules§
- sync
sync
Synchronous implementation of the lock.
Structs§
- A distributed mutual exclusion lock backed by Redis.
Enums§
- Error for
MultiResourceLock::map
.
Constants§
- Default expiration duration for the lock.
- Default sleep duration between attempts to acquire the lock.
- Default timeout duration for acquiring the lock.
Functions§
- Initializes a Redis instance with the Lua library functions required for locking.