From fd1c18c0887321934f89e38ab9d62b677128fffb Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 30 Jan 2017 17:00:24 +0000 Subject: [PATCH 1/2] Use DB cache of joined users for presence --- synapse/handlers/presence.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 1b89dc6274..9982ae0fed 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -574,7 +574,7 @@ class PresenceHandler(object): if not local_states: continue - users = yield self.state.get_current_user_in_room(room_id) + users = yield self.store.get_users_in_room(room_id) hosts = set(get_domain_from_id(u) for u in users) for host in hosts: @@ -766,7 +766,7 @@ class PresenceHandler(object): # don't need to send to local clients here, as that is done as part # of the event stream/sync. # TODO: Only send to servers not already in the room. - user_ids = yield self.state.get_current_user_in_room(room_id) + user_ids = yield self.store.get_users_in_room(room_id) if self.is_mine(user): state = yield self.current_state_for_user(user.to_string()) @@ -1069,7 +1069,7 @@ class PresenceEventSource(object): user_ids_to_check = set() for room_id in room_ids: - users = yield self.state.get_current_user_in_room(room_id) + users = yield self.store.get_users_in_room(room_id) user_ids_to_check.update(users) user_ids_to_check.update(friends) From 4b3403ca9b87a8187ea597027a82be9fe005cfb9 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 30 Jan 2017 17:24:32 +0000 Subject: [PATCH 2/2] Stream cache invalidations for room membership storage functions --- synapse/storage/events.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/synapse/storage/events.py b/synapse/storage/events.py index 8712d7e18c..6685b9da1c 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -564,9 +564,13 @@ class EventsStore(SQLBaseStore): ) for member in members_changed: - txn.call_after(self.get_rooms_for_user.invalidate, (member,)) + self._invalidate_cache_and_stream( + txn, self.get_rooms_for_user, (member,) + ) - txn.call_after(self.get_users_in_room.invalidate, (room_id,)) + self._invalidate_cache_and_stream( + txn, self.get_users_in_room, (room_id,) + ) # Add an entry to the current_state_resets table to record the point # where we clobbered the current state