Skip to content

Commit 7835678

Browse files
perf: Assistant api
1 parent 7bf5418 commit 7835678

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

backend/apps/system/api/assistant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def info(session: SessionDep, id: str, virtual: Optional[int] = Query(None
4545

4646
@router.get("", response_model=list[AssistantModel])
4747
async def query(session: SessionDep):
48-
list_result = session.exec(select(AssistantModel).order_by(AssistantModel.create_time)).all()
48+
list_result = session.exec(select(AssistantModel).order_by(AssistantModel.create_time.asc())).all()
4949
return list_result
5050

5151
@router.post("")

backend/common/core/sqlbot_cache.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ async def wrapper(*args, **kwargs):
164164
)
165165

166166
async with _get_cache_lock(cache_key):
167-
await FastAPICache.clear(key=cache_key)
168-
result = await func(*args, **kwargs)
169-
logging.info(f"Clearing cache for key: {cache_key}")
170-
print(f"Clearing cache for key: {cache_key}")
171-
return result
167+
if await FastAPICache.get_backend().get(cache_key):
168+
await FastAPICache.clear(key=cache_key)
169+
result = await func(*args, **kwargs)
170+
logging.info(f"Clearing cache for key: {cache_key}")
171+
print(f"Clearing cache for key: {cache_key}")
172+
return result
173+
return await func(*args, **kwargs)
172174

173175
return wrapper
174176
return decorator

0 commit comments

Comments
 (0)