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]

refactor(proxy): read the shared sign-in counter through a tuple of keys

yucheng04b7b7165615
diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.py
index 6b93529e456..f37ca8a23a1 100644
--- a/litellm/caching/redis_cache.py
+++ b/litellm/caching/redis_cache.py
@@ -791,7 +791,7 @@ class RedisCache(BaseCache):
return _LUA_COUNT.validate_python(count)
@_redis_circuit_breaker_guard_sync
- def batch_get_counts(self, key_list: list[str]) -> tuple[int | None, ...]:
+ def batch_get_counts(self, key_list: Sequence[str]) -> tuple[int | None, ...]:
"""Read integer counters for ``key_list``, in order, raising when Redis cannot answer.
``batch_get_cache`` swallows every failure and returns an empty dict, which the caller
@@ -802,7 +802,7 @@ class RedisCache(BaseCache):
return _decoded_counts(self._run_redis_mget_operation(keys=namespaced_keys))
@_redis_circuit_breaker_guard
- async def async_batch_get_counts(self, key_list: list[str]) -> tuple[int | None, ...]:
+ async def async_batch_get_counts(self, key_list: Sequence[str]) -> tuple[int | None, ...]:
"""Async twin of ``batch_get_counts``, raising on failure the same way."""
namespaced_keys: Final = [self.check_and_fix_namespace(key=key) for key in key_list]
return _decoded_counts(await self._async_run_redis_mget_operation(keys=namespaced_keys))
diff --git a/litellm/proxy/auth/login_throttle.py b/litellm/proxy/auth/login_throttle.py
index ca73bb4f26b..5a56628bed2 100644
--- a/litellm/proxy/auth/login_throttle.py
+++ b/litellm/proxy/auth/login_throttle.py
@@ -207,7 +207,7 @@ class LoginThrottle:
``async_get_cache`` turns a failed GET into ``None``, which would pass as an empty counter.
"""
local: Final = _as_count(await self._outcome(store.async_get_cache(key=key)))
- shared: Final = await self._shared(lambda redis_cache: redis_cache.async_batch_get_counts([key]))
+ shared: Final = await self._shared(lambda redis_cache: redis_cache.async_batch_get_counts((key,)))
if not isinstance(shared, tuple):
return local
return _as_count(shared[0]) + local