gc method

Set<String> gc()

Removes all entities that cannot be reached from one of the root operations.

Implementation

Set<String> gc() {
  final reachable = utils.reachableIds(
    (dataId) => store.get(dataId),
    typePolicies,
  );
  final keysToRemove = store.keys
      .where(
        (key) =>
            !reachable.contains(key) && !_retainedEntityIds.contains(key),
      )
      .toSet();
  store.deleteAll(keysToRemove);
  return keysToRemove;
}