Crates.io | rdlock |
lib.rs | rdlock |
version | 1.0.3 |
source | src |
created_at | 2024-10-24 00:40:50.820445 |
updated_at | 2024-10-25 03:43:40.152816 |
description | A library for distributed redis locks written in rust |
homepage | |
repository | https://github.com/RedaOps/rdlock |
max_upload_size | |
id | 1420734 |
size | 25,206 |
A library for distributed redis locks written in rust.
These are some useful synchronization primitives which work among multiple separate processes, servers and clusters, as long as they communicate with the same redis server.
The redis instance must have notify-keyspace-events
enabled with at least KA
flags.
If this is too much overhead for your current instance, consider running a separate redis instance just for the distributed locks.
Usage and examples on docs.rs
BasicLock
- a basic type of distributed lock with no protected data. This is the most basic synchronization primitive.It uses redis SET with the NX option enabled for creating a "lockfile".
Any lock
function that waits for the lock to become available (e.g: .lock()
or .lock_timeout()
) will use redis pubsub in order to monitor for changes and try to acquire the "lockfile" once it is available.
pubsub
drops while waiting for a lock and/or we miss a message, we will never acquire it, since redis pubsub is fire and forget.src/lock/mod.rs
Types of locks we want implemented:
Please note this is a work in progress and for starters I will be implementing only what I need or want to have fun with. If there is a certain synchronization primitive that is not available and you need it or you want to implement it for fun, contributions are always welcome :)