summary refs log tree commit diff
path: root/synapse/storage/roommember.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-03-24 11:46:22 +0000
committerErik Johnston <erik@matrix.org>2017-03-24 11:46:24 +0000
commit7fc1f1e2b68ad45e74bec122c31e30efd64599af (patch)
tree90710050cfa75c974418a104c96ef440f8eec90a /synapse/storage/roommember.py
parentMerge pull request #2054 from matrix-org/erikj/user_iter_cursor (diff)
downloadsynapse-7fc1f1e2b68ad45e74bec122c31e30efd64599af.tar.xz
Cache hosts in room
Diffstat (limited to 'synapse/storage/roommember.py')
-rw-r--r--synapse/storage/roommember.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index 23127d3a95..367dbbbcf6 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -129,6 +129,16 @@ class RoomMemberStore(SQLBaseStore):
         with self._stream_id_gen.get_next() as stream_ordering:
             yield self.runInteraction("locally_reject_invite", f, stream_ordering)
 
+    @cachedInlineCallbacks(max_entries=100000, iterable=True, cache_context=True)
+    def get_hosts_in_room(self, room_id, cache_context):
+        """Returns the set of all hosts currently in the room
+        """
+        user_ids = yield self.get_users_in_room(
+            room_id, on_invalidate=cache_context.invalidate,
+        )
+        hosts = frozenset(get_domain_from_id(user_id) for user_id in user_ids)
+        defer.returnValue(hosts)
+
     @cached(max_entries=500000, iterable=True)
     def get_users_in_room(self, room_id):
         def f(txn):