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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redlock-dist-1.0.1.tar.gz
(2.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redlock-dist-1.0.1.tar.gz.
File metadata
- Download URL: redlock-dist-1.0.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d00d3755357aac8e7256fcf9a4de004601b3b0c842cf53ed00ff8b93991d56de
|
|
| MD5 |
04f686330809fe3b8a78290c7ff3e9e7
|
|
| BLAKE2b-256 |
9c5088d591e2b3c03e41837633acf29a08721eecbcd464e4c56bf0cf5aeebbbe
|
File details
Details for the file redlock_dist-1.0.1-py3-none-any.whl.
File metadata
- Download URL: redlock_dist-1.0.1-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
685e3a7b39fbf87415b21596221c21ba9aa78a4d25976fe651facc9e2e52f532
|
|
| MD5 |
2565248e47b4e5fa0504fa23af9ed069
|
|
| BLAKE2b-256 |
39795daa7401b8eab0e035943ff8a675fbbdad2356ae23988ea7598242952318
|