From c77dae7a1abfef19940efd1378df5e2215a5b48b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 23 Feb 2016 14:48:23 +0000 Subject: Change the way we figure out presence updates for small deltas --- synapse/util/caches/stream_change_cache.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'synapse/util') diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py index b37f1c0725..970488a19c 100644 --- a/synapse/util/caches/stream_change_cache.py +++ b/synapse/util/caches/stream_change_cache.py @@ -85,6 +85,22 @@ class StreamChangeCache(object): return result + def get_all_entities_changed(self, stream_pos): + """Returns all entites that have had new things since the given + position. If the position is too old it will return None. + """ + assert type(stream_pos) is int + + if stream_pos >= self._earliest_known_stream_pos: + keys = self._cache.keys() + i = keys.bisect_right(stream_pos) + + return ( + self._cache[k] for k in keys[i:] + ) + else: + return None + def entity_has_changed(self, entity, stream_pos): """Informs the cache that the entity has been changed at the given position. -- cgit 1.4.1