Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Use DB cache of joined users for presence #1862

Merged
merged 3 commits into from
Jan 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion synapse/handlers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def notify_device_update(self, user_id, device_ids):
hosts = set()
if self.hs.is_mine_id(user_id):
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)
hosts.update(get_domain_from_id(u) for u in users)
hosts.discard(self.server_name)

Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def _get_interested_parties(self, states, calculate_remote_hosts=True):
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:
Expand Down Expand Up @@ -766,7 +766,7 @@ def user_joined_room(self, user, room_id):
# 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())

Expand Down Expand Up @@ -1069,7 +1069,7 @@ def get_new_events(self, user, from_key, room_ids=None, include_offline=True,

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)
Expand Down
8 changes: 6 additions & 2 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,13 @@ def _persist_events_txn(self, txn, events_and_contexts, backfilled,
)

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
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def f(txn, stream_ordering):
with self._stream_id_gen.get_next() as stream_ordering:
yield self.runInteraction("locally_reject_invite", f, stream_ordering)

@cached(max_entries=5000)
@cached(max_entries=1000000, iterable=True)
def get_users_in_room(self, room_id):
def f(txn):

Expand Down