diff options
author | Erik Johnston <erikj@jki.re> | 2016-09-15 15:48:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-15 15:48:53 +0100 |
commit | ea6dc356b08f76988c5616290750bdd85758627c (patch) | |
tree | 018742ba107f80e11636a630b2e2fadc13b8b226 | |
parent | Merge pull request #1124 from matrix-org/erikj/enable_state_caching_workers (diff) | |
parent | Change get_pos_of_last_change to return upper bound (diff) | |
download | synapse-ea6dc356b08f76988c5616290750bdd85758627c.tar.xz |
Merge pull request #1125 from matrix-org/erikj/public_room_cache
Change get_pos_of_last_change to return upper bound
Diffstat (limited to '')
-rw-r--r-- | synapse/storage/event_federation.py | 5 | ||||
-rw-r--r-- | synapse/util/caches/stream_change_cache.py | 7 |
2 files changed, 6 insertions, 6 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py index 97d0c26475..59b4cf1e53 100644 --- a/synapse/storage/event_federation.py +++ b/synapse/storage/event_federation.py @@ -347,9 +347,8 @@ class EventFederationStore(SQLBaseStore): def get_forward_extremeties_for_room(self, room_id, stream_ordering): # We want to make the cache more effective, so we clamp to the last # change before the given ordering. - last_change = self._events_stream_cache.get_pos_of_last_change(room_id) - if last_change: - stream_ordering = min(last_change, stream_ordering) + last_change = self._events_stream_cache.get_max_pos_of_last_change(room_id) + stream_ordering = min(last_change, stream_ordering) return self._get_forward_extremeties_for_room(room_id, stream_ordering) diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py index 5c2a433e41..b72bb0ff02 100644 --- a/synapse/util/caches/stream_change_cache.py +++ b/synapse/util/caches/stream_change_cache.py @@ -122,7 +122,8 @@ class StreamChangeCache(object): self._earliest_known_stream_pos = max(k, self._earliest_known_stream_pos) self._entity_to_key.pop(r, None) - def get_pos_of_last_change(self, entity): - """Returns the stream pos of the last change for an entitiy, if known. + def get_max_pos_of_last_change(self, entity): + """Returns an upper bound of the stream id of the last change to an + entity. """ - return self._entity_to_key.get(entity, None) + return self._entity_to_key.get(entity, self._earliest_known_stream_pos) |