loro icon indicating copy to clipboard operation
loro copied to clipboard

feat: empty tree trash

Open Leeeon233 opened this issue 1 year ago • 1 comments

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.

Leeeon233 avatar Jul 24 '24 09:07 Leeeon233

Does this PR include the tests for:

  • JSON import/export schema (the related doc also needs updating)
  • Forward & Backward Compatibility

zxch3n avatar Aug 04 '24 07:08 zxch3n

closed by gc mode

Leeeon233 avatar Sep 23 '24 03:09 Leeeon233