loro
loro copied to clipboard
feat: empty tree trash
This PR provides a new function called empty_trash() to clean up all caches under the TRASH node of the Tree Container.
We model the operation of deleting a node by moving the target node to a specific TRASH node, enabling concurrent moves of the target node to be applied as well.
All deleted nodes and their hierarchical relationships are cached even though they may never reappear. However, they still occupy memory. So we need gc them.
Example
const loro = new Loro();
const tree = loro.getTree("root");
const root = tree.createNode();
const child = tree.createNode(root.id);
const child2 = tree.createNode(root.id);
tree.delete(child.id);
tree.delete(child2.id);
tree.emptyTrash();
loro.commit();
Breaking Change
- A new Op has been added to the Tree Container, making the older version incompatible with this version. (But if no new Op is used, it does not affect the compatibility.
Does this PR include the tests for:
- JSON import/export schema (the related doc also needs updating)
- Forward & Backward Compatibility
closed by gc mode