0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-18 08:43:53 +01:00

Merge pull request #1125 from matrix-org/erikj/public_room_cache

Change get_pos_of_last_change to return upper bound
This commit is contained in:
Erik Johnston 2016-09-15 15:48:53 +01:00 committed by GitHub
commit ea6dc356b0
2 changed files with 6 additions and 6 deletions

View file

@ -347,9 +347,8 @@ class EventFederationStore(SQLBaseStore):
def get_forward_extremeties_for_room(self, room_id, stream_ordering): 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 # We want to make the cache more effective, so we clamp to the last
# change before the given ordering. # change before the given ordering.
last_change = self._events_stream_cache.get_pos_of_last_change(room_id) last_change = self._events_stream_cache.get_max_pos_of_last_change(room_id)
if last_change: stream_ordering = min(last_change, stream_ordering)
stream_ordering = min(last_change, stream_ordering)
return self._get_forward_extremeties_for_room(room_id, stream_ordering) return self._get_forward_extremeties_for_room(room_id, stream_ordering)

View file

@ -122,7 +122,8 @@ class StreamChangeCache(object):
self._earliest_known_stream_pos = max(k, self._earliest_known_stream_pos) self._earliest_known_stream_pos = max(k, self._earliest_known_stream_pos)
self._entity_to_key.pop(r, None) self._entity_to_key.pop(r, None)
def get_pos_of_last_change(self, entity): def get_max_pos_of_last_change(self, entity):
"""Returns the stream pos of the last change for an entitiy, if known. """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)