https://github.com/lingfromsh/pyredis-distribution-lock
Distribution Lock implemented by python3 + redis
https://github.com/lingfromsh/pyredis-distribution-lock
Last synced: 3 months ago
JSON representation
Distribution Lock implemented by python3 + redis
- Host: GitHub
- URL: https://github.com/lingfromsh/pyredis-distribution-lock
- Owner: lingfromSh
- Created: 2021-09-01T07:12:04.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-12T02:24:36.000Z (over 3 years ago)
- Last Synced: 2025-01-09T03:51:19.585Z (5 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PyRedis Distribution Lock
## Introduction
It's just a simple implementation of distribution lock.
We could use redis distribution lock to manipulate some shared resources safely in distributed context.
## Tests
You could quickly test
```shell
python3 -m tests.xxx
```## Quick Start
You could take adventage of a redis distribution lock in a very simple way.
```python3
import redis
import lockr = redis.Redis(host='localhost', port=6379, db=0)
# if-else
def deduct_inventory(...):
lock = lock.RedisDistributionLock()
if lock.acquire(...):
...
lock.release()# with
def deduct_inventory(...):
with lock.RedisDistributionLock():
...
```