mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 04:23:54 +01:00
Add a response cache for getting the public room list
This commit is contained in:
parent
191c7bef6b
commit
54a546091a
1 changed files with 11 additions and 1 deletions
|
@ -25,6 +25,7 @@ from synapse.api.constants import (
|
||||||
from synapse.api.errors import AuthError, StoreError, SynapseError, Codes
|
from synapse.api.errors import AuthError, StoreError, SynapseError, Codes
|
||||||
from synapse.util import stringutils, unwrapFirstError
|
from synapse.util import stringutils, unwrapFirstError
|
||||||
from synapse.util.logcontext import preserve_context_over_fn
|
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.sign import verify_signed_json
|
||||||
from signedjson.key import decode_verify_key_bytes
|
from signedjson.key import decode_verify_key_bytes
|
||||||
|
@ -939,9 +940,18 @@ class RoomMemberHandler(BaseHandler):
|
||||||
|
|
||||||
|
|
||||||
class RoomListHandler(BaseHandler):
|
class RoomListHandler(BaseHandler):
|
||||||
|
def __init__(self, hs):
|
||||||
|
super(RoomListHandler, self).__init__(hs)
|
||||||
|
self.response_cache = ResponseCache()
|
||||||
|
|
||||||
|
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
|
@defer.inlineCallbacks
|
||||||
def get_public_room_list(self):
|
def _get_public_room_list(self):
|
||||||
room_ids = yield self.store.get_public_room_ids()
|
room_ids = yield self.store.get_public_room_ids()
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
Loading…
Reference in a new issue