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(caching): accept read-only sequences for redis rpush pipeline payloads

shivam5212e8c1f1a1
diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.py
index 5fedfc5bcce..a3936fd17e2 100644
--- a/litellm/caching/redis_cache.py
+++ b/litellm/caching/redis_cache.py
@@ -1572,7 +1572,7 @@ class RedisCache(BaseCache):
async def _pipeline_rpush_helper(
self,
pipe: pipeline,
- rpush_list: list[RedisPipelineRpushOperation],
+ rpush_list: Sequence[RedisPipelineRpushOperation],
) -> list[int]:
"""Helper function for pipeline rpush operations"""
for rpush_op in rpush_list:
@@ -1588,7 +1588,7 @@ class RedisCache(BaseCache):
@_redis_circuit_breaker_guard
async def async_rpush_pipeline(
self,
- rpush_list: list[RedisPipelineRpushOperation],
+ rpush_list: Sequence[RedisPipelineRpushOperation],
) -> list[int]:
"""
Use Redis Pipelines for bulk RPUSH operations
diff --git a/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py b/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py
index 573da72b873..853c033c37e 100644
--- a/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py
+++ b/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py
@@ -407,11 +407,11 @@ class RedisUpdateBuffer:
(daily_tag_spend_update_transactions, REDIS_DAILY_TAG_SPEND_UPDATE_BUFFER_KEY),
)
- rpush_list: Final[list[RedisPipelineRpushOperation]] = [ # mutable-ok: async_rpush_pipeline requires a list arg
- RedisPipelineRpushOperation(key=redis_key, values=[safe_dumps(transactions)])
+ rpush_list: Final = tuple(
+ RedisPipelineRpushOperation(key=redis_key, values=(safe_dumps(transactions),))
for transactions, redis_key in restore_configs
if transactions
- ]
+ )
if len(rpush_list) == 0:
return
diff --git a/litellm/types/caching.py b/litellm/types/caching.py
index 6616a2e9bac..427904d2fe2 100644
--- a/litellm/types/caching.py
+++ b/litellm/types/caching.py
@@ -1,3 +1,4 @@
+from collections.abc import Sequence
from enum import Enum
from typing import Any, Final, Literal, Optional, Union
@@ -59,7 +60,7 @@ class RedisPipelineRpushOperation(TypedDict):
"""
key: str
- values: list[Any]
+ values: Sequence[Any]
class RedisPipelineLpopOperation(TypedDict):
diff --git a/type-discipline-budget.json b/type-discipline-budget.json
index 894d99c92e0..94565199516 100644
--- a/type-discipline-budget.json
+++ b/type-discipline-budget.json
@@ -1,6 +1,6 @@
{
"LIT001": {
- "limit": 22941
+ "limit": 22938
},
"LIT002": {
"limit": 27139