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
refactor pod lock manager to use redis
Ishaan Jaff2e939a21b388
diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.pyindex 63cd4d09598..1d553c9c80d 100644--- a/litellm/caching/redis_cache.py+++ b/litellm/caching/redis_cache.py@@ -303,13 +303,19 @@ class RedisCache(BaseCache):raise ekey = self.check_and_fix_namespace(key=key)- ttl = self.get_ttl(**kwargs)+ ttl = self.get_ttl(**kwargs) or kwargs.get("ex", None)+ nx = kwargs.get("nx", False)print_verbose(f"Set ASYNC Redis Cache: key: {key}\nValue {value}\nttl={ttl}")try:if not hasattr(_redis_client, "set"):raise Exception("Redis client cannot set cache. Attribute not found.")- await _redis_client.set(name=key, value=json.dumps(value), ex=ttl)+ result = await _redis_client.set(+ name=key,+ value=json.dumps(value),+ nx=nx,+ ex=ttl,+ )print_verbose(f"Successfully Set ASYNC Redis Cache: key: {key}\nValue {value}\nttl={ttl}")@@ -326,6 +332,7 @@ class RedisCache(BaseCache):event_metadata={"key": key},))+ return resultexcept Exception as e:end_time = time.time()_duration = end_time - start_time@@ -931,7 +938,7 @@ class RedisCache(BaseCache):# typed as Any, redis python lib has incomplete type stubs for RedisCluster and does not include `delete`_redis_client: Any = self.init_async_client()# keys is str- await _redis_client.delete(key)+ return await _redis_client.delete(key)def delete_cache(self, key):self.redis_client.delete(key)