summary refs log tree commit diff
path: root/synapse/util/caches
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-02-23 15:18:41 +0000
committerErik Johnston <erik@matrix.org>2016-02-23 15:18:41 +0000
commite3e0ac6ec7128ff7fc7306a3fdf02d9f98dfc472 (patch)
tree5f0753de360e4cef8c5cef6efa1158f6e2e95bca /synapse/util/caches
parentSet WORKSPACE if not set (diff)
parentHandle get_all_entities_changed returning None (diff)
downloadsynapse-e3e0ac6ec7128ff7fc7306a3fdf02d9f98dfc472.tar.xz
Merge pull request #602 from matrix-org/erikj/presence
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.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.