summary refs log tree commit diff
path: root/synapse/util/caches/stream_change_cache.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-02-23 14:48:23 +0000
committerErik Johnston <erik@matrix.org>2016-02-23 14:54:40 +0000
commitc77dae7a1abfef19940efd1378df5e2215a5b48b (patch)
treef1ba371d65f818519fd0477b8fd531ec091ef742 /synapse/util/caches/stream_change_cache.py
parentDon't include defer.returnValue in Measure block (diff)
downloadsynapse-c77dae7a1abfef19940efd1378df5e2215a5b48b.tar.xz
Change the way we figure out presence updates for small deltas
Diffstat (limited to 'synapse/util/caches/stream_change_cache.py')
-rw-r--r--synapse/util/caches/stream_change_cache.py16
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.