diff --git a/litellm/caching.py b/litellm/caching.py index aa8ab7bef..a0aa1e3ff 100644 --- a/litellm/caching.py +++ b/litellm/caching.py @@ -334,6 +334,9 @@ class RedisCache(BaseCache): def flush_cache(self): self.redis_client.flushall() + def flushall(self): + self.redis_client.flushall() + async def disconnect(self): await self.async_redis_conn_pool.disconnect(inuse_connections=True) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index c301cd779..e2ae4fb8f 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -7754,13 +7754,20 @@ async def cache_ping(): @router.post( - "/cache/flush", + "/cache/flushall", tags=["caching"], dependencies=[Depends(user_api_key_auth)], ) -async def cache_flush(): +async def cache_flushall(): """ - Endpoint for checking if cache can be pinged + A function to flush all items from the cache + Raises HTTPException if the cache is not initialized or if the cache type does not support flushing. + Returns a dictionary with the status of the operation. + + Usage: + ``` + curl -X POST http://0.0.0.0:4000/cache/flushall -H "Authorization: Bearer sk-1234" + ``` """ try: if litellm.cache is None: