redis-lock-0.2.0 has been yanked.
redis-lock
Rusty distributed locking backed by Redis.
// Setup.
setup.await?;
let mut lock = new?;
let mut conn = client.get_multiplexed_async_connection.await?;
let from = "account1";
let to = "account2";
let resources = vec!;
// Acquire lock.
let opt = lock.lock_default.await?;
let guard = opt.ok_or?;
// Perform transfer.
let amount = 500;
let from_balance: i64 = conn.get.await?;
// Execute transaction if the sender has enough funds.
if from_balance >= amount
// Lock releases when dropped.
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.