summary refs log tree commit diff
path: root/synapse/util/caches
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-01-29 15:52:42 +0000
committerErik Johnston <erik@matrix.org>2016-01-29 15:52:42 +0000
commitc1de91aca466bf8e5e711c2042535505bb02a08d (patch)
tree370b9c0a378d168511d132919e381d1f97133463 /synapse/util/caches
parentMerge pull request #541 from matrix-org/erikj/fixsomeofpush (diff)
parentComment. Remove superfluous order by (diff)
downloadsynapse-c1de91aca466bf8e5e711c2042535505bb02a08d.tar.xz
Merge pull request #540 from matrix-org/erikj/sync
Prefill stream change caches
Diffstat (limited to 'synapse/util/caches')
-rw-r--r--synapse/util/caches/stream_change_cache.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py
index c673b1bdfc..891cb619fa 100644
--- a/synapse/util/caches/stream_change_cache.py
+++ b/synapse/util/caches/stream_change_cache.py
@@ -32,7 +32,7 @@ class StreamChangeCache(object):
     entities that may have changed since that position. If position key is too
     old then the cache will simply return all given entities.
     """
-    def __init__(self, name, current_stream_pos, max_size=10000):
+    def __init__(self, name, current_stream_pos, max_size=10000, prefilled_cache={}):
         self._max_size = max_size
         self._entity_to_key = {}
         self._cache = sorteddict()
@@ -40,6 +40,9 @@ class StreamChangeCache(object):
         self.name = name
         caches_by_name[self.name] = self._cache
 
+        for entity, stream_pos in prefilled_cache.items():
+            self.entity_has_changed(entity, stream_pos)
+
     def has_entity_changed(self, entity, stream_pos):
         """Returns True if the entity may have been updated since stream_pos
         """