mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-10 21:49:59 -04:00
Add cache for get_membership_from_event_ids
(#12272)
This should speed up push rule calculations for rooms with large numbers of local users when the main push rule cache fails. Co-authored-by: reivilibre <oliverw@matrix.org>
This commit is contained in:
parent
38adf14998
commit
7ca8ee67a5
6 changed files with 72 additions and 22 deletions
|
@ -1023,8 +1023,13 @@ class EventsPersistenceStorage:
|
|||
|
||||
# Check if any of the changes that we don't have events for are joins.
|
||||
if events_to_check:
|
||||
rows = await self.main_store.get_membership_from_event_ids(events_to_check)
|
||||
is_still_joined = any(row["membership"] == Membership.JOIN for row in rows)
|
||||
members = await self.main_store.get_membership_from_event_ids(
|
||||
events_to_check
|
||||
)
|
||||
is_still_joined = any(
|
||||
member and member.membership == Membership.JOIN
|
||||
for member in members.values()
|
||||
)
|
||||
if is_still_joined:
|
||||
return True
|
||||
|
||||
|
@ -1060,9 +1065,11 @@ class EventsPersistenceStorage:
|
|||
), event_id in current_state.items()
|
||||
if typ == EventTypes.Member and not self.is_mine_id(state_key)
|
||||
]
|
||||
rows = await self.main_store.get_membership_from_event_ids(remote_event_ids)
|
||||
members = await self.main_store.get_membership_from_event_ids(remote_event_ids)
|
||||
potentially_left_users.update(
|
||||
row["user_id"] for row in rows if row["membership"] == Membership.JOIN
|
||||
member.user_id
|
||||
for member in members.values()
|
||||
if member and member.membership == Membership.JOIN
|
||||
)
|
||||
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue