From 8bb00c4ae838ac81c885c691e321845db19701c3 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 20 Mar 2024 18:42:34 -0700 Subject: [PATCH] fix(caching.py): enable async setting of cache for dual cache --- litellm/caching.py | 11 +++++++++++ litellm/proxy/proxy_server.py | 2 -- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/litellm/caching.py b/litellm/caching.py index 66f030098c9..ba46d85a79e 100644 --- a/litellm/caching.py +++ b/litellm/caching.py @@ -836,6 +836,17 @@ class DualCache(BaseCache): except Exception as e: traceback.print_exc() + async def async_set_cache(self, key, value, local_only: bool = False, **kwargs): + try: + if self.in_memory_cache is not None: + await self.in_memory_cache.async_set_cache(key, value, **kwargs) + + if self.redis_cache is not None and local_only == False: + await self.redis_cache.async_set_cache(key, value, **kwargs) + except Exception as e: + print_verbose(f"LiteLLM Cache: Excepton async add_cache: {str(e)}") + traceback.print_exc() + def flush_cache(self): if self.in_memory_cache is not None: self.in_memory_cache.flush_cache() diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 2c0cd92edf5..6bdf9d33d46 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -409,8 +409,6 @@ async def user_api_key_auth( models=user_object.models, user_role="app_owner", ) - else: - raise Exception("Invalid key error!") #### ELSE #### if master_key is None: if isinstance(api_key, str):