This commit is contained in:
HotSwapp
2025-08-18 20:20:04 -05:00
parent 89b2bc0aa2
commit bac8cc4bd5
114 changed files with 30258 additions and 1341 deletions

View File

@@ -368,8 +368,10 @@ async def advanced_search(
# Cache lookup keyed by user and entire criteria (including pagination)
try:
cached = await cache_get_json(
kind="advanced",
from app.services.adaptive_cache import adaptive_cache_get
cached = await adaptive_cache_get(
cache_type="advanced",
cache_key="advanced_search",
user_id=str(getattr(current_user, "id", "")),
parts={"criteria": criteria.model_dump(mode="json")},
)
@@ -438,14 +440,15 @@ async def advanced_search(
page_info=page_info,
)
# Store in cache (best-effort)
# Store in cache with adaptive TTL
try:
await cache_set_json(
kind="advanced",
user_id=str(getattr(current_user, "id", "")),
parts={"criteria": criteria.model_dump(mode="json")},
from app.services.adaptive_cache import adaptive_cache_set
await adaptive_cache_set(
cache_type="advanced",
cache_key="advanced_search",
value=response.model_dump(mode="json"),
ttl_seconds=90,
user_id=str(getattr(current_user, "id", "")),
parts={"criteria": criteria.model_dump(mode="json")}
)
except Exception:
pass
@@ -462,9 +465,11 @@ async def global_search(
):
"""Enhanced global search across all entities"""
start_time = datetime.now()
# Cache lookup
cached = await cache_get_json(
kind="global",
# Cache lookup with adaptive tracking
from app.services.adaptive_cache import adaptive_cache_get
cached = await adaptive_cache_get(
cache_type="global",
cache_key="global_search",
user_id=str(getattr(current_user, "id", "")),
parts={"q": q, "limit": limit},
)
@@ -505,12 +510,13 @@ async def global_search(
phones=phone_results[:limit]
)
try:
await cache_set_json(
kind="global",
user_id=str(getattr(current_user, "id", "")),
parts={"q": q, "limit": limit},
from app.services.adaptive_cache import adaptive_cache_set
await adaptive_cache_set(
cache_type="global",
cache_key="global_search",
value=response.model_dump(mode="json"),
ttl_seconds=90,
user_id=str(getattr(current_user, "id", "")),
parts={"q": q, "limit": limit}
)
except Exception:
pass