forked from MirrorHub/synapse
Add cache to get_state_groups
This commit is contained in:
parent
d8866d7277
commit
0d7d9c37b6
1 changed files with 12 additions and 8 deletions
|
@ -81,19 +81,23 @@ class StateStore(SQLBaseStore):
|
||||||
f,
|
f,
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
state_list = yield defer.gatherResults(
|
||||||
def c(vals):
|
|
||||||
vals[:] = yield self._get_events(vals, get_prev_content=False)
|
|
||||||
|
|
||||||
yield defer.gatherResults(
|
|
||||||
[
|
[
|
||||||
c(vals)
|
self._fetch_events_for_group(group, vals)
|
||||||
for vals in states.values()
|
for group, vals in states.items()
|
||||||
],
|
],
|
||||||
consumeErrors=True,
|
consumeErrors=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
defer.returnValue(states)
|
defer.returnValue(dict(state_list))
|
||||||
|
|
||||||
|
@cached(num_args=1)
|
||||||
|
def _fetch_events_for_group(self, state_group, events):
|
||||||
|
return self._get_events(
|
||||||
|
events, get_prev_content=False
|
||||||
|
).addCallback(
|
||||||
|
lambda evs: (state_group, evs)
|
||||||
|
)
|
||||||
|
|
||||||
def _store_state_groups_txn(self, txn, event, context):
|
def _store_state_groups_txn(self, txn, event, context):
|
||||||
if context.current_state is None:
|
if context.current_state is None:
|
||||||
|
|
Loading…
Reference in a new issue