Open ghost opened 12 years ago
Yeah, support for removing items is currently very half-baked. I added rem()
primarily to clean up my test teardown methods, but realized there would probably be value in keeping it in.
The problem with removing nodes in general is that in the current master there are only unidirectional edges between nodes, pointing from "child" nodes to "parent" nodes. As such, a node is only aware of things that are dependent on itself, but isn't aware of things it depends on. When a node is removed entirely from the graph, the correct thing to do is to remove any edges going to it, but right now there isn't enough information to do that.
To fix this problem, I'm currently working on adding bidirectional links defining edges between nodes. Rather than <id>:deps
keys, there will be <id>:out
and <id>:in
keys. Once this exists, rem()
will be more useful.
Adding support for delete-if-orphaned
is interesting, but I'd have to put some more thought into it. It strikes me as possibly being very expensive.
Say I have a structure where
post1
is dependent oncomment1
,comment2
, andcomment3
.post1
, I'd want to also get rid ofcomment1
,comment2
, andcomment3
, as they would no longer be used. But instead, here, they'd linger on, unneeded, clogging up my Stash.post2
also depended oncomment1
, I'd want to not delete it along withpost1
, as long as something still referenced it.My idea would be to mark certain entities as delete-if-orphaned, and, when an entity depending on them is deleted/invalidated, they would also be removed. Not sure if that's the best way to go about this, though.