From 0981ee1af9cbbeb72d42d4e830c997304bba5a32 Mon Sep 17 00:00:00 2001 From: yangdx Date: Mon, 31 Mar 2025 23:23:31 +0800 Subject: [PATCH] Replace delete() with drop_cache_by_modes() method to implement cache clearing operations --- lightrag/lightrag.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index 81797385..7077f94d 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -1894,12 +1894,18 @@ class LightRAG: try: # Reset the cache storage for specified mode if modes: - await self.llm_response_cache.delete(modes) - logger.info(f"Cleared cache for modes: {modes}") + success = await self.llm_response_cache.drop_cache_by_modes(modes) + if success: + logger.info(f"Cleared cache for modes: {modes}") + else: + logger.warning(f"Failed to clear cache for modes: {modes}") else: # Clear all modes - await self.llm_response_cache.delete(valid_modes) - logger.info("Cleared all cache") + success = await self.llm_response_cache.drop_cache_by_modes(valid_modes) + if success: + logger.info("Cleared all cache") + else: + logger.warning("Failed to clear all cache") await self.llm_response_cache.index_done_callback()