Change the way we figure out presence updates for small deltas

This commit is contained in:
Erik Johnston 2016-02-23 14:48:23 +00:00
parent 02e928cf9b
commit c77dae7a1a
2 changed files with 52 additions and 17 deletions

View file

@ -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.