From 40a2357c14b2328f737d9e22dde70864481a9404 Mon Sep 17 00:00:00 2001 From: yangdx Date: Mon, 28 Apr 2025 23:16:50 +0800 Subject: [PATCH] Persistence cache data to disk before exiting --- lightrag/kg/json_kv_impl.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lightrag/kg/json_kv_impl.py b/lightrag/kg/json_kv_impl.py index 62f7289d..2d44ce00 100644 --- a/lightrag/kg/json_kv_impl.py +++ b/lightrag/kg/json_kv_impl.py @@ -197,3 +197,10 @@ class JsonKVStorage(BaseKVStorage): except Exception as e: logger.error(f"Error dropping {self.namespace}: {e}") return {"status": "error", "message": str(e)} + + async def finalize(self): + """Finalize storage resources + Persistence cache data to disk before exiting + """ + if self.namespace.endswith("cache"): + await self.index_done_callback()