mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-23 00:41:40 +00:00
refactor(proxy): read the shared sign-in counter through a tuple of keys
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
383edfe953
commit
04b7b71656
2 changed files with 3 additions and 3 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue