mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-17 04:34:25 +00:00
test(proxy): give the spend counter test fakes the reset fence hook
CountingRedis skipped RedisCache.__init__ and _ExpiringRedisCache never had reset_fence_key, so the repair's broad except swallowed the AttributeError and the counter stayed stale in five tests
This commit is contained in:
parent
244cae37d4
commit
4e2d6ab15f
2 changed files with 4 additions and 0 deletions
|
|
@ -41,6 +41,7 @@ class CountingRedis(RedisCache):
|
|||
self.store: dict[str, object] = dict(store or {})
|
||||
self.fail = fail
|
||||
self.commands: list[str] = []
|
||||
self.namespace = None
|
||||
|
||||
async def async_get_cache(self, key: str, **kwargs: object) -> object:
|
||||
if self.fail:
|
||||
|
|
|
|||
|
|
@ -2366,6 +2366,9 @@ class _ExpiringRedisCache:
|
|||
self.expires_at[key] = self._expiry(kwargs.get("ttl"))
|
||||
return self.store[key]
|
||||
|
||||
def reset_fence_key(self, key: str) -> str:
|
||||
return f"{{{key}}}:reset_fence"
|
||||
|
||||
async def async_set_max(self, key: str, value: float, **kwargs: object) -> float:
|
||||
self._evict_expired(key)
|
||||
self.store[key] = max(self.store.get(key, float("-inf")), float(value))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue