summary refs log tree commit diff
path: root/synapse/util/caches
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-05-31 15:46:36 +0100
committerErik Johnston <erik@matrix.org>2017-05-31 15:46:36 +0100
commit304880d18545b59a51c5d4b928e563c6d1514fdc (patch)
tree38c43a4062f1a283f3d689784fadaee2a6bfc0ea /synapse/util/caches
parentSplit out directory and search tables (diff)
downloadsynapse-304880d18545b59a51c5d4b928e563c6d1514fdc.tar.xz
Add stream change cache
Diffstat (limited to 'synapse/util/caches')
-rw-r--r--synapse/util/caches/stream_change_cache.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py
index 70fe00ce0b..c498aee46c 100644
--- a/synapse/util/caches/stream_change_cache.py
+++ b/synapse/util/caches/stream_change_cache.py
@@ -89,6 +89,21 @@ class StreamChangeCache(object):
 
         return result
 
+    def has_any_entity_changed(self, stream_pos):
+        """Returns if any entity has changed
+        """
+        assert type(stream_pos) is int
+
+        if stream_pos >= self._earliest_known_stream_pos:
+            self.metrics.inc_hits()
+            if stream_pos >= max(self._cache):
+                return False
+            else:
+                return True
+        else:
+            self.metrics.inc_misses()
+            return True
+
     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.