summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-06-01 14:55:02 +0100
committerErik Johnston <erik@matrix.org>2015-06-01 14:55:02 +0100
commit689b4de31454bd1496c6216d9a82c134bc87abd4 (patch)
treedfdc1ebbd9911d569270da02f0a7fc2f0a7afaef
parentMerge pull request #172 from intelfx/contrib-systemd (diff)
downloadsynapse-689b4de31454bd1496c6216d9a82c134bc87abd4.tar.xz
Also cache user_id -> UserID conversion
-rw-r--r--synapse/handlers/room.py4
-rw-r--r--synapse/storage/events.py1
-rw-r--r--synapse/storage/roommember.py7
3 files changed, 9 insertions, 3 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 4bd027d9bb..31efba0a9c 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -254,9 +254,7 @@ class RoomMemberHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def get_room_members(self, room_id):
-        users = yield self.store.get_users_in_room(room_id)
-
-        defer.returnValue([UserID.from_string(u) for u in users])
+        return self.store.get_user_objs_in_room(room_id)
 
     @defer.inlineCallbacks
     def fetch_room_distributions_into(self, room_id, localusers=None,
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index 20a8d81794..79cb52beb0 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -128,6 +128,7 @@ class EventsStore(SQLBaseStore):
             txn.call_after(self.get_current_state_for_key.invalidate_all)
             txn.call_after(self.get_rooms_for_user.invalidate_all)
             txn.call_after(self.get_users_in_room.invalidate, event.room_id)
+            txn.call_after(self.get_user_objs_in_room.invalidate, event.room_id)
             txn.call_after(self.get_joined_hosts_for_room.invalidate, event.room_id)
             txn.call_after(self.get_room_name_and_aliases, event.room_id)
 
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index d36a6c18a8..2c879d56d6 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -67,6 +67,7 @@ class RoomMemberStore(SQLBaseStore):
         txn.call_after(self.get_rooms_for_user.invalidate, target_user_id)
         txn.call_after(self.get_joined_hosts_for_room.invalidate, event.room_id)
         txn.call_after(self.get_users_in_room.invalidate, event.room_id)
+        txn.call_after(self.get_user_objs_in_room.invalidate, event.room_id)
 
     def get_room_member(self, user_id, room_id):
         """Retrieve the current state of a room member.
@@ -101,6 +102,12 @@ class RoomMemberStore(SQLBaseStore):
             return [r["user_id"] for r in rows]
         return self.runInteraction("get_users_in_room", f)
 
+    @cached()
+    def get_user_objs_in_room(self, room_id):
+        return self.get_users_in_room(room_id).addCallback(
+            lambda users: [UserID.from_string(u) for u in users]
+        )
+
     def get_room_members(self, room_id, membership=None):
         """Retrieve the current room member list for a room.