mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 04:23:54 +01:00
If stream pos is greater then earliest known key and entity hasn't changed, then entity hasn't changed
This commit is contained in:
parent
c1de91aca4
commit
e70165039c
1 changed files with 3 additions and 8 deletions
|
@ -52,15 +52,10 @@ class StreamChangeCache(object):
|
||||||
cache_counter.inc_misses(self.name)
|
cache_counter.inc_misses(self.name)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if stream_pos == self._earliest_known_stream_pos:
|
|
||||||
# If the same as the earliest key, assume nothing has changed.
|
|
||||||
cache_counter.inc_hits(self.name)
|
|
||||||
return False
|
|
||||||
|
|
||||||
latest_entity_change_pos = self._entity_to_key.get(entity, None)
|
latest_entity_change_pos = self._entity_to_key.get(entity, None)
|
||||||
if latest_entity_change_pos is None:
|
if latest_entity_change_pos is None:
|
||||||
cache_counter.inc_misses(self.name)
|
cache_counter.inc_hits(self.name)
|
||||||
return True
|
return False
|
||||||
|
|
||||||
if stream_pos < latest_entity_change_pos:
|
if stream_pos < latest_entity_change_pos:
|
||||||
cache_counter.inc_misses(self.name)
|
cache_counter.inc_misses(self.name)
|
||||||
|
@ -98,7 +93,7 @@ class StreamChangeCache(object):
|
||||||
|
|
||||||
if stream_pos > self._earliest_known_stream_pos:
|
if stream_pos > self._earliest_known_stream_pos:
|
||||||
old_pos = self._entity_to_key.get(entity, None)
|
old_pos = self._entity_to_key.get(entity, None)
|
||||||
if old_pos:
|
if old_pos is not None:
|
||||||
stream_pos = max(stream_pos, old_pos)
|
stream_pos = max(stream_pos, old_pos)
|
||||||
self._cache.pop(old_pos, None)
|
self._cache.pop(old_pos, None)
|
||||||
self._cache[stream_pos] = entity
|
self._cache[stream_pos] = entity
|
||||||
|
|
Loading…
Reference in a new issue