redlock-dist
Implementation of distributed locking with Redis
Usage
Install:
pip install redlock-dist
example:
from redis import StrictRedis
from redlock_dist import RedLock
rds = StrictRedis(host='localhost', port=6379, db=0)
"""
:param expire: lock key ttl(ms)
:param retry_times: retry times to get lock
:param retry_interval: retry interval(ms)
"""
with RedLock(rds, 'key-name', expires=30000, retry_times=3, retry_interval=50) as red_lock:
if red_lock:
print('get lock')
else:
print('do not get lock')
Principle and notes
Because Redis is single-threaded and you can use SET key value NX PX expires
Metadata
Release files for redlock-dist 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| redlock-dist-1.0.1.tar.gz | 2.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| redlock_dist-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.7 kB
Release files / redlock-dist-1.0.1.tar.gz
| Download URL | redlock-dist-1.0.1.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d00d3755357aac8e7256fcf9a4de004601b3b0c842cf53ed00ff8b93991d56de
|
|
BLAKE2b-256 checksum How to use checksums |
9c5088d591e2b3c03e41837633acf29a08721eecbcd464e4c56bf0cf5aeebbbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / redlock_dist-1.0.1-py3-none-any.whl
| Download URL | redlock_dist-1.0.1-py3-none-any.whl |
|---|---|
| Size | 2.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
685e3a7b39fbf87415b21596221c21ba9aa78a4d25976fe651facc9e2e52f532
|
|
BLAKE2b-256 checksum How to use checksums |
39795daa7401b8eab0e035943ff8a675fbbdad2356ae23988ea7598242952318
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |