diff options
author | Erik Johnston <erikj@jki.re> | 2017-02-02 15:20:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-02 15:20:14 +0000 |
commit | a8331897aab4d223460f634fcb7ba4b091e183f1 (patch) | |
tree | d330b3a8265a481db2d0e55352c8ec1f0f32359d /synapse/storage | |
parent | Merge pull request #1875 from matrix-org/erikj/fix_email_push (diff) | |
parent | Fix replication (diff) | |
download | synapse-a8331897aab4d223460f634fcb7ba4b091e183f1.tar.xz |
Merge pull request #1876 from matrix-org/erikj/shared_member_store
Make presence.get_new_events a bit faster
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/roommember.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py index ee800d074f..249217e114 100644 --- a/synapse/storage/roommember.py +++ b/synapse/storage/roommember.py @@ -280,6 +280,23 @@ 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): + """Returns the set of users who share a room with `user_id` + """ + 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, + ) + 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): |