From 689221b5c72c2a1728ae0710fe1d27f4e6c7434f Mon Sep 17 00:00:00 2001 From: Rahul Kataria Date: Sun, 12 May 2024 17:04:18 +0530 Subject: [PATCH] [Optimize] Optimize code in caching file --- litellm/caching.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/caching.py b/litellm/caching.py index 466f4d18631..ccb62b8827e 100644 --- a/litellm/caching.py +++ b/litellm/caching.py @@ -373,11 +373,12 @@ class RedisCache(BaseCache): print_verbose( f"Set ASYNC Redis Cache PIPELINE: key: {cache_key}\nValue {cache_value}\nttl={ttl}" ) + json_cache_value = json.dumps(cache_value) # Set the value with a TTL if it's provided. if ttl is not None: - pipe.setex(cache_key, ttl, json.dumps(cache_value)) + pipe.setex(cache_key, ttl, json_cache_value) else: - pipe.set(cache_key, json.dumps(cache_value)) + pipe.set(cache_key, json_cache_value) # Execute the pipeline and return the results. results = await pipe.execute()