feat: Remove immediate persistence in delete operation for JsonDocStatusStorage

This commit is contained in:
yangdx
2025-03-31 14:46:36 +08:00
parent 81f887ebab
commit 2cb64ad280

View File

@@ -123,11 +123,23 @@ class JsonDocStatusStorage(DocStatusStorage):
return self._data.get(id) return self._data.get(id)
async def delete(self, doc_ids: list[str]): async def delete(self, doc_ids: list[str]):
"""Delete specific records from storage by their IDs
This method will:
1. Remove the specified records from in-memory storage
2. Update flags to notify other processes that data persistence is needed
3. The changes will be persisted to disk during the next index_done_callback
Args:
ids (list[str]): List of document IDs to be deleted from storage
Returns:
None
"""
async with self._storage_lock: async with self._storage_lock:
for doc_id in doc_ids: for doc_id in doc_ids:
self._data.pop(doc_id, None) self._data.pop(doc_id, None)
await set_all_update_flags(self.namespace) await set_all_update_flags(self.namespace)
await self.index_done_callback()
async def drop(self) -> dict[str, str]: async def drop(self) -> dict[str, str]:
"""Drop all document status data from storage and clean up resources """Drop all document status data from storage and clean up resources