diff options
author | Mark Haines <mjark@negativecurvature.net> | 2016-03-24 18:07:30 +0000 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2016-03-24 18:07:30 +0000 |
commit | 3e8bb99a2b6bca8aca329c3cca92114435833f83 (patch) | |
tree | 83f7846ffa872486bf98a3012e818f429ec26829 /synapse/handlers/room.py | |
parent | Merge pull request #667 from matrix-org/dbkr/never_notify_member_events (diff) | |
parent | Fix typo (diff) | |
download | synapse-3e8bb99a2b6bca8aca329c3cca92114435833f83.tar.xz |
Merge pull request #668 from matrix-org/markjh/deduplicate
Deduplicate identical /sync requests
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r-- | synapse/handlers/room.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index d5c56ce0d6..133183a257 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -25,6 +25,7 @@ from synapse.api.constants import ( from synapse.api.errors import AuthError, StoreError, SynapseError, Codes from synapse.util import stringutils, unwrapFirstError from synapse.util.logcontext import preserve_context_over_fn +from synapse.util.caches.response_cache import ResponseCache from signedjson.sign import verify_signed_json from signedjson.key import decode_verify_key_bytes @@ -939,9 +940,18 @@ class RoomMemberHandler(BaseHandler): class RoomListHandler(BaseHandler): + def __init__(self, hs): + super(RoomListHandler, self).__init__(hs) + self.response_cache = ResponseCache() - @defer.inlineCallbacks def get_public_room_list(self): + result = self.response_cache.get(()) + if not result: + result = self.response_cache.set((), self._get_public_room_list()) + return result + + @defer.inlineCallbacks + def _get_public_room_list(self): room_ids = yield self.store.get_public_room_ids() @defer.inlineCallbacks |