File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,6 @@ async def validateToken(self, token: Optional[str]):
6363 with Session (engine ) as session :
6464 session_user = await get_user_info (session = session , user_id = token_data .id )
6565 session_user = UserInfoDTO .model_validate (session_user )
66- session_user = UserInfoDTO .model_validate (session_user )
6766 """ if token_data.oid != session_user.oid:
6867 raise HTTPException(
6968 status_code=401,
Original file line number Diff line number Diff line change 88import random
99from collections import defaultdict
1010
11+ from apps .system .schemas .auth import CacheName
12+ from apps .system .schemas .system_schema import UserInfoDTO
1113from common .utils .utils import SQLBotLogUtil
1214
1315# 使用contextvar来跟踪当前线程已持有的锁
@@ -118,6 +120,9 @@ async def wrapper(*args, **kwargs):
118120 # 双重检查
119121 if (cached := await backend .get (cache_key )) is not None :
120122 SQLBotLogUtil .debug (f"Cache hit: { cache_key } " )
123+ if CacheName .USER_INFO .value in cache_key :
124+ user = UserInfoDTO .model_validate (cached )
125+ SQLBotLogUtil .info (f"User cache hit: [uid: { user .id } , account: { user .account } , oid: { user .oid } ]" )
121126 return cached
122127
123128 # 执行函数并缓存结果
@@ -129,6 +134,9 @@ async def wrapper(*args, **kwargs):
129134 await backend .set (cache_key , result , actual_expire )
130135
131136 SQLBotLogUtil .debug (f"Cache set: { cache_key } (expire: { actual_expire } s)" )
137+ if CacheName .USER_INFO .value in cache_key :
138+ user = UserInfoDTO .model_validate (result )
139+ SQLBotLogUtil .info (f"User cache set: [uid: { user .id } , account: { user .account } , oid: { user .oid } ]" )
132140 return result
133141
134142 return wrapper
You can’t perform that action at this time.
0 commit comments