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]

fix redis async_set_cache_pipeline when empty list passed to it (#5962)

Ishaan Jaff750085565437
diff --git a/litellm/caching.py b/litellm/caching.py
index b2632be6796..efd43cde382 100644
--- a/litellm/caching.py
+++ b/litellm/caching.py
@@ -461,6 +461,9 @@ class RedisCache(BaseCache):
"""
Use Redis Pipelines for bulk write operations
"""
+ # don't waste a network request if there's nothing to set
+ if len(cache_list) == 0:
+ return
from redis.asyncio import Redis
_redis_client: Redis = self.init_async_client() # type: ignore