+ def _add_to_cache(self, using, node, qs=None):
+ if node is None or node.pk is None:
+ qs = self.none()
+ key = None
+ else:
+ key = node.pk
+
+ if qs is None:
+ qs = node.hosted_navigation.select_related('target_node')
+
+ self.__class__._cache.setdefault(using, {})[key] = qs
+
+ def _get_from_cache(self, using, node):
+ key = node.pk
+ return self.__class__._cache[self.db][key]
+
+ def _is_cached(self, using, node):
+ try:
+ self._get_from_cache(using, node)
+ except KeyError:
+ return False
+ return True
+