Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(auth): keep prefetched org entries on the 5s getter TTL

Shivi Jain75b16df6fa38
diff --git a/litellm/proxy/auth/auth_object_prefetch.py b/litellm/proxy/auth/auth_object_prefetch.py
index 5efc45d3fce..52e26e885c9 100644
--- a/litellm/proxy/auth/auth_object_prefetch.py
+++ b/litellm/proxy/auth/auth_object_prefetch.py
@@ -14,6 +14,7 @@ from pydantic import BaseModel, TypeAdapter, ValidationError
from litellm._logging import verbose_proxy_logger
from litellm.caching.redis_cache import RedisCache
+from litellm.constants import DEFAULT_IN_MEMORY_TTL
from litellm.models.organization import LiteLLM_OrganizationTable
from litellm.models.team import LiteLLM_TeamTableCachedObj
from litellm.models.team_membership import LiteLLM_TeamMembership
@@ -190,13 +191,13 @@ def _iter_entries(refs: AuthObjectRefs, management_ttl: float) -> Iterator[_Cach
)
if refs.organization_id is not None:
yield _CacheEntry(
- f"org_id:{refs.organization_id}", "organization_row", LiteLLM_OrganizationTable, management_ttl
+ f"org_id:{refs.organization_id}", "organization_row", LiteLLM_OrganizationTable, DEFAULT_IN_MEMORY_TTL
)
yield _CacheEntry(
f"org_id:{refs.organization_id}:with_budget",
"organization_row",
LiteLLM_OrganizationTable,
- management_ttl,
+ DEFAULT_IN_MEMORY_TTL,
)
if refs.project_id is not None:
yield _CacheEntry(f"project_id:{refs.project_id}", "project_row", LiteLLM_ProjectTableCachedObj, management_ttl)
diff --git a/tests/test_litellm/proxy/auth/test_auth_object_prefetch.py b/tests/test_litellm/proxy/auth/test_auth_object_prefetch.py
index 58761e270a0..0fd0dda3017 100644
--- a/tests/test_litellm/proxy/auth/test_auth_object_prefetch.py
+++ b/tests/test_litellm/proxy/auth/test_auth_object_prefetch.py
@@ -181,8 +181,8 @@ async def test_cold_regime_is_one_mget_one_query_and_the_getters_never_touch_io_
assert sets == sorted(
[
f"SET {TEAM_ID}_{USER_ID} ttl=5",
- f"SET org_id:{ORG_ID} ttl=60",
- f"SET org_id:{ORG_ID}:with_budget ttl=60",
+ f"SET org_id:{ORG_ID} ttl=5",
+ f"SET org_id:{ORG_ID}:with_budget ttl=5",
f"SET {USER_ID} ttl=60",
f"SET team_id:{TEAM_ID} ttl=60",
f"SET team_membership:{USER_ID}:{TEAM_ID} ttl=None",