1 unstable release
new 0.3.0 | Oct 24, 2024 |
---|---|
0.2.0 |
|
0.1.2 |
|
0.1.1 |
|
0.1.0 |
|
#651 in Database interfaces
563 downloads per month
34KB
635 lines
redis-lock
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 does operations that require exclusive access to multiple resources.
Similar work
lib.rs
:
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
Dependencies
~7–16MB
~226K SLoC