Merge pull request #2060 from matrix-org/erikj/cache_hosts_in_room
Cache hosts in room
This commit is contained in:
commit
23e0ff840a
|
@ -575,8 +575,7 @@ class PresenceHandler(object):
|
||||||
if not local_states:
|
if not local_states:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
users = yield self.store.get_users_in_room(room_id)
|
hosts = yield self.store.get_hosts_in_room(room_id)
|
||||||
hosts = set(get_domain_from_id(u) for u in users)
|
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
hosts_to_states.setdefault(host, []).extend(local_states)
|
hosts_to_states.setdefault(host, []).extend(local_states)
|
||||||
|
|
|
@ -129,6 +129,16 @@ class RoomMemberStore(SQLBaseStore):
|
||||||
with self._stream_id_gen.get_next() as stream_ordering:
|
with self._stream_id_gen.get_next() as stream_ordering:
|
||||||
yield self.runInteraction("locally_reject_invite", f, 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)
|
@cached(max_entries=500000, iterable=True)
|
||||||
def get_users_in_room(self, room_id):
|
def get_users_in_room(self, room_id):
|
||||||
def f(txn):
|
def f(txn):
|
||||||
|
|
Loading…
Reference in New Issue