async-redis-lock
A simple and easy-to-use asynchronous redis distributed lock implementation based on tokio and redis-rs.
Key Features
- ✨ Auto Extension - Automatically extends lock lifetime in background until released
- 🔒 Passive Release - Lock automatically releases when lifetime expires after process crash
- 🎯 Drop Support - Supports both implicit release via drop and explicit release via method call
- 🔗 Multi-key Locking - Ability to lock multiple keys simultaneously ensuring atomic operations across them
Quick Start
Installation
[]
= "0.2.1"
Basic Usage
use Locker;
async
Automatic Release
use Locker;
async
Advanced Configuration
use Locker;
use Options;
use Duration;
async
Important Notes
- Don't ignore the return value of acquire method, or the lock will release immediately
- If the extension interval is too large, the lock extension may fail because the lock has been passively released (by expiration) before the extension attempt, the recommend is ttl/3
- Lock implements Drop trait and will auto-release when out of scope
License
MIT
Contributions and suggestions are welcome!