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(caching): treat an empty cache namespace as no namespace
mateo-berri57f553aec834
diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.pyindex d12f2066cf1..f1c80eaacbe 100644--- a/litellm/caching/redis_cache.py+++ b/litellm/caching/redis_cache.py@@ -435,7 +435,7 @@ class RedisCache(BaseCache):"""if key is None:return key- if self.namespace is not None and not key.startswith(self.namespace + ":"):+ if self.namespace and not key.startswith(self.namespace + ":"):key = self.namespace + ":" + keyreturn keydiff --git a/tests/test_litellm/caching/test_redis_cache.py b/tests/test_litellm/caching/test_redis_cache.pyindex 915e5eac45d..487a64797d1 100644--- a/tests/test_litellm/caching/test_redis_cache.py+++ b/tests/test_litellm/caching/test_redis_cache.py@@ -25,6 +25,7 @@ def redis_no_ping():("litellm", "litellm:3997c4abcdef", "litellm:3997c4abcdef"),("litellm", "spend:key:3997c4abcdef", "litellm:spend:key:3997c4abcdef"),(None, "litellm_spend_update_buffer", "litellm_spend_update_buffer"),+ ("", "litellm_spend_update_buffer", "litellm_spend_update_buffer"),],)def test_check_and_fix_namespace_prefixes_keys_sharing_the_namespace_prefix(