mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:16:07 -04:00
Add stream change cache
This commit is contained in:
parent
5d79d728f5
commit
304880d185
4 changed files with 34 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue