增加接口日志输出
This commit is contained in:
@@ -3,6 +3,9 @@ import asyncio
|
||||
import uuid
|
||||
from typing import Optional
|
||||
from app.config import settings
|
||||
from app.logger import get_logger
|
||||
|
||||
logger = get_logger("redis")
|
||||
|
||||
|
||||
class RedisLock:
|
||||
@@ -15,6 +18,8 @@ class RedisLock:
|
||||
|
||||
async def acquire(self) -> bool:
|
||||
"""获取分布式锁"""
|
||||
logger.debug(f"🔒 尝试获取Redis锁: {self.key}")
|
||||
|
||||
lua_script = """
|
||||
if redis.call("GET", KEYS[1]) == false then
|
||||
return redis.call("SETEX", KEYS[1], ARGV[1], ARGV[2])
|
||||
@@ -32,6 +37,11 @@ class RedisLock:
|
||||
)
|
||||
|
||||
self.acquired = bool(result)
|
||||
if self.acquired:
|
||||
logger.debug(f"✅ Redis锁获取成功: {self.key}")
|
||||
else:
|
||||
logger.debug(f"❌ Redis锁获取失败: {self.key}")
|
||||
|
||||
return self.acquired
|
||||
|
||||
async def release(self) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user