mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-11 12:31:58 +01:00
Always use state cache entry if it exists
Also check if the resolved state matches an existing state group.
This commit is contained in:
parent
4cf4320593
commit
5bbc321588
1 changed files with 10 additions and 3 deletions
|
@ -214,7 +214,7 @@ class StateHandler(object):
|
||||||
|
|
||||||
if self._state_cache is not None:
|
if self._state_cache is not None:
|
||||||
cache = self._state_cache.get(group_names, None)
|
cache = self._state_cache.get(group_names, None)
|
||||||
if cache and cache.state_group:
|
if cache:
|
||||||
cache.ts = self.clock.time_msec()
|
cache.ts = self.clock.time_msec()
|
||||||
|
|
||||||
event_dict = yield self.store.get_events(cache.state.values())
|
event_dict = yield self.store.get_events(cache.state.values())
|
||||||
|
@ -236,16 +236,23 @@ class StateHandler(object):
|
||||||
state_groups.values(), event_type, state_key
|
state_groups.values(), event_type, state_key
|
||||||
)
|
)
|
||||||
|
|
||||||
|
state_group = None
|
||||||
|
new_state_event_ids = frozenset(e.event_id for e in new_state.values())
|
||||||
|
for sg, events in state_groups.items():
|
||||||
|
if new_state_event_ids == frozenset(e.event_id for e in events):
|
||||||
|
state_group = sg
|
||||||
|
break
|
||||||
|
|
||||||
if self._state_cache is not None:
|
if self._state_cache is not None:
|
||||||
cache = _StateCacheEntry(
|
cache = _StateCacheEntry(
|
||||||
state={key: event.event_id for key, event in new_state.items()},
|
state={key: event.event_id for key, event in new_state.items()},
|
||||||
state_group=None,
|
state_group=state_group,
|
||||||
ts=self.clock.time_msec()
|
ts=self.clock.time_msec()
|
||||||
)
|
)
|
||||||
|
|
||||||
self._state_cache[group_names] = cache
|
self._state_cache[group_names] = cache
|
||||||
|
|
||||||
defer.returnValue((None, new_state, prev_states))
|
defer.returnValue((state_group, new_state, prev_states))
|
||||||
|
|
||||||
def resolve_events(self, state_sets, event):
|
def resolve_events(self, state_sets, event):
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
Loading…
Reference in a new issue