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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(proxy): build Redis spend-log rows as tuples and pin the LTRIM window in the pipeline test
yassin65bf78b567db
diff --git a/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py b/litellm/proxy/db/db_transaction_queue/redis_update_buffer.pyindex 9044bbb3d3b..534ba30a6d0 100644--- a/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py+++ b/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py@@ -554,7 +554,7 @@ class RedisUpdateBuffer:try:buffer_size: Final = await self.redis_cache.async_rpush_and_trim(key=REDIS_SPEND_LOGS_BUFFER_KEY,- values=[_encode_spend_log_row(row) for row in rows],+ values=tuple(_encode_spend_log_row(row) for row in rows),max_len=max_rows,)overflow: Final = buffer_size - max_rows@@ -582,7 +582,7 @@ class RedisUpdateBuffer:)if popped is None:return ()- encoded_rows: Final = popped if isinstance(popped, list) else [popped]+ encoded_rows: Final = tuple(popped) if isinstance(popped, list) else (popped,)decoded_rows: Final = (_decode_spend_log_row(encoded) for encoded in encoded_rows)return tuple(row for row in decoded_rows if row is not None)diff --git a/tests/test_litellm/caching/test_redis_cache.py b/tests/test_litellm/caching/test_redis_cache.pyindex 44227b8ed33..5d72fe7213d 100644--- a/tests/test_litellm/caching/test_redis_cache.py+++ b/tests/test_litellm/caching/test_redis_cache.py@@ -1549,4 +1549,4 @@ async def test_async_rpush_and_trim_runs_push_and_trim_in_one_transaction(monkeyclient.pipeline.assert_called_once_with(transaction=True)assert pushed_len == 4assert rows == ["b", "c", "d"]- assert [op[:2] for op in pipe.queued] == [("rpush", "ns:buf"), ("ltrim", "ns:buf")]+ assert pipe.queued == [("rpush", "ns:buf", "c", "d"), ("ltrim", "ns:buf", "-3", "-1")]