mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Correctly update _entity_to_key
This commit is contained in:
parent
82cf3a8043
commit
40431251cb
@ -82,18 +82,19 @@ class StreamChangeCache(object):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def entity_has_changed(self, entitiy, stream_pos):
|
def entity_has_changed(self, entity, stream_pos):
|
||||||
"""Informs the cache that the entitiy has been changed at the given
|
"""Informs the cache that the entity has been changed at the given
|
||||||
position.
|
position.
|
||||||
"""
|
"""
|
||||||
assert type(stream_pos) is int
|
assert type(stream_pos) is int
|
||||||
|
|
||||||
if stream_pos > self._earliest_known_stream_pos:
|
if stream_pos > self._earliest_known_stream_pos:
|
||||||
old_pos = self._entity_to_key.get(entitiy, None)
|
old_pos = self._entity_to_key.get(entity, None)
|
||||||
if old_pos:
|
if old_pos:
|
||||||
stream_pos = max(stream_pos, old_pos)
|
stream_pos = max(stream_pos, old_pos)
|
||||||
self._cache.pop(old_pos, None)
|
self._cache.pop(old_pos, None)
|
||||||
self._cache[stream_pos] = entitiy
|
self._cache[stream_pos] = entity
|
||||||
|
self._entity_to_key[entity] = stream_pos
|
||||||
|
|
||||||
while len(self._cache) > self._max_size:
|
while len(self._cache) > self._max_size:
|
||||||
k, r = self._cache.popitem()
|
k, r = self._cache.popitem()
|
||||||
|
Loading…
Reference in New Issue
Block a user