Skip to main content

Distributed locks with Redis

Project description

redlock-dist

Implementation of distributed locking with Redis

Distributed locks 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)

with RedLock(rds, 'key-name') 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

Project details


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.0.tar.gz (2.1 kB view hashes)

Uploaded Source

Built Distribution

redlock_dist-1.0.0-py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page