mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 10:56:06 -04:00
Prefill stream change caches
This commit is contained in:
parent
ebc5f00efe
commit
18579534ea
4 changed files with 52 additions and 19 deletions
|
@ -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
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue