+ def clear_cache_for(self, node):
+ """Clear the cache for a node and all its descendants"""
+ self._clear_cache_for(self.db, node)
+
+ def _clear_cache_for(self, using, node):
+ # Clear the cache for all descendants of the node. Ideally we would
+ # only clear up to another hosting node, but the complexity is not
+ # necessary and may not be possible.
+ descendants = node.get_descendants(include_self=True)
+ cache = self.__class__._cache[using]
+ for node in descendants:
+ cache.pop(node, None)
+