mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:36:02 -04:00
Make presence.get_new_events a bit faster
We do this by caching the set of users a user shares rooms with.
This commit is contained in:
parent
14d5e22700
commit
54a79c1d37
4 changed files with 33 additions and 29 deletions
|
@ -280,6 +280,22 @@ class RoomMemberStore(SQLBaseStore):
|
|||
user_id, membership_list=[Membership.JOIN],
|
||||
)
|
||||
|
||||
@cachedInlineCallbacks(max_entries=50000, cache_context=True, iterable=True)
|
||||
def get_users_who_share_room_with_user(self, user_id, cache_context):
|
||||
rooms = yield self.get_rooms_for_user(
|
||||
user_id, on_invalidate=cache_context.invalidate,
|
||||
)
|
||||
|
||||
user_who_share_room = set()
|
||||
for room in rooms:
|
||||
user_ids = yield self.get_users_in_room(
|
||||
room.room_id, on_invalidate=cache_context.invalidate,
|
||||
)
|
||||
logger.info("Users in room: %r %r", room.room_id, user_ids)
|
||||
user_who_share_room.update(user_ids)
|
||||
|
||||
defer.returnValue(user_who_share_room)
|
||||
|
||||
def forget(self, user_id, room_id):
|
||||
"""Indicate that user_id wishes to discard history for room_id."""
|
||||
def f(txn):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue