代码拉取完成,页面将自动刷新
A simple lock extension for django's cache to prevent concurrent editing.
Install django-cache-lock by using pip
pip install django-cache-lock
You can work with django-cache-lock by using with-statement or decorator.
from django_lock import lock
with lock("global"):
pass
@lock("global")
def foo():
pass
A shortcut to lock model instance
from django.db import models
from django_lock import model_lock
class Foo(models.Model):
bar = models.CharField(max_length=8)
@lock_model
def lock_pk(self):
pass
@lock_model("bar", blocking=False)
def lock_bar(self):
pass
key | default | desc |
---|---|---|
DJANGOLOCK_PREFIX | "lock:" | lock's key prefix stored in cache |
DJANGOLOCK_SLEEP | 0.1 | default interval time to acquire a lock if a lock is holded by others |
DJANGOLOCK_RELEASEONDEL | True | release lock when __del__ is called if True |
For more usages, please read the code.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型