Skip to content

Commit 7426844

Browse files
feat(search): add lru_cache to qdrant client and get_model
1 parent 613cd1f commit 7426844

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/app/services/search.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import time
2-
from functools import cache
2+
from functools import cache, lru_cache
33
from typing import Tuple, cast
44

55
import numpy as np
@@ -49,6 +49,7 @@ async def close_qdrant():
4949
await _qdrant_client.close()
5050

5151

52+
@lru_cache(maxsize=1)
5253
async def get_qdrant() -> AsyncQdrantClient | None:
5354
if qdrant_client is None:
5455
raise Error()
@@ -149,7 +150,7 @@ def get_query_embed(
149150

150151
return embedding
151152

152-
@cache
153+
@lru_cache(maxsize=1)
153154
@log_time_and_error_sync
154155
def _get_model(self, curr_model: str) -> tuple[int | None, SentenceTransformer]:
155156
try:

0 commit comments

Comments
 (0)