第一次提交:小程序前端最新版本

This commit is contained in:
XingQue
2026-06-14 02:38:05 +08:00
commit 5e90f7c87c
677 changed files with 153758 additions and 0 deletions

18
utils/redis_lock.py Normal file
View File

@@ -0,0 +1,18 @@
import redis
from django.conf import settings
redis_client = redis.Redis(
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
password=settings.REDIS_PASSWORD,
db=2,
decode_responses=True
)
def acquire_lock(lock_key, timeout=10):
"""获取锁,返回是否成功"""
return redis_client.set(lock_key, '1', nx=True, ex=timeout)
def release_lock(lock_key):
"""释放锁"""
redis_client.delete(lock_key)