Redlock+¶
Redlock+ is an up to date, feature complete implementation of the Redlock Algorithm It’s a spiritual successor to glasslion/redlock, which is no longer maintained.
Features¶
Compliant with the standard library Lock and RLock so it can be used as a drop-in replacement
Complete implementation of the Redlock Algorithm
Autoextend functionality to make redlock safer and easier to use
Well tested (Python 3.6+, PyPy3)
Type hinted
Documentation¶
Basic usage¶
from redlock_plus import Lock
redis_instance_configs = [
{"url": "redis://localhost/0"},
{"url": "redis://example.com:1234/1"},
{"url": "redis://other.host:5678/2"},
]
with Lock("my_resource", redis_instance_configs):
# do work
or speed up things for repeated use using the factory
from redlock_plus import LockFactory
redlock_factory = LockFactory(
[
{"url": "redis://localhost/0"},
{"url": "redis://localhost/1"},
{"url": "redis://localhost/2"},
]
)
with redlock_factory("my_resource"):
# do work