MCPcopy Index your code
hub / github.com/ormar-orm/ormar / update_cache

Method update_cache

ormar/relations/relation_proxy.py:102–117  ·  view source on GitHub ↗

Updates the cache from the old hash to the new one. This maintains the index cache, which allows O(1) indexing and existence checks :param prev_hash: The hash to update :type prev_hash: int :param prev_hash: The new hash to update to :type ne

(self, prev_hash: int, new_hash: int)

Source from the content-addressed store, hash-verified

100 super().append(item)
101
102 def update_cache(self, prev_hash: int, new_hash: int) -> None:
103 """
104 Updates the cache from the old hash to the new one.
105 This maintains the index cache, which allows O(1) indexing and
106 existence checks
107
108 :param prev_hash: The hash to update
109 :type prev_hash: int
110 :param prev_hash: The new hash to update to
111 :type new_hash: int
112 """
113 try:
114 idx = self._relation_cache.pop(prev_hash)
115 self._relation_cache[new_hash] = idx
116 except KeyError:
117 pass
118
119 def index(self, item: T, *args: Any) -> int:
120 """

Callers 1

_update_cacheMethod · 0.80

Calls 1

popMethod · 0.80

Tested by

no test coverage detected