diff options
author | Erik Johnston <erik@matrix.org> | 2016-02-23 14:48:23 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-02-23 14:54:40 +0000 |
commit | c77dae7a1abfef19940efd1378df5e2215a5b48b (patch) | |
tree | f1ba371d65f818519fd0477b8fd531ec091ef742 /synapse/util/caches | |
parent | Don't include defer.returnValue in Measure block (diff) | |
download | synapse-c77dae7a1abfef19940efd1378df5e2215a5b48b.tar.xz |
Change the way we figure out presence updates for small deltas
Diffstat (limited to 'synapse/util/caches')
-rw-r--r-- | synapse/util/caches/stream_change_cache.py | 16 |
1 files changed, 16 insertions, 0 deletions
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. |