From ac06ddfb02b49da85db5be7f584bdbd0f90323cf Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 18 Dec 2024 18:58:46 -0600 Subject: [PATCH] Better `all_entities_changed(stream_pos)` implementation See https://github.com/element-hq/synapse/pull/17732#discussion_r1765815711 --- synapse/util/caches/stream_change_cache.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py index 522cba3825..5ac8643eef 100644 --- a/synapse/util/caches/stream_change_cache.py +++ b/synapse/util/caches/stream_change_cache.py @@ -319,11 +319,9 @@ class StreamChangeCache: Mark all entities as changed. This is useful when the cache is invalidated and there may be some potential change for all of the entities. """ - # All entities are at the same stream position now. - self._cache = SortedDict({stream_pos: set(self._entity_to_key.keys())}) - self._entity_to_key = { - entity: stream_pos for entity in self._entity_to_key.keys() - } + self._cache.clear() + self._entity_to_key.clear() + self._earliest_known_stream_pos = stream_pos def _evict(self) -> None: """