diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2018-04-20 11:31:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-20 11:31:17 +0100 |
commit | 11a67b7c9db0da43eb5d9a8df4a0410cbf031d6a (patch) | |
tree | 5c4f2338436ddfc28b4293bf658921519a6168dc /synapse/replication/http | |
parent | Merge pull request #3117 from matrix-org/rav/refactor_have_events (diff) | |
parent | Reinstate linearizer for federation_server.on_context_state_request (diff) | |
download | synapse-11a67b7c9db0da43eb5d9a8df4a0410cbf031d6a.tar.xz |
Merge pull request #3093 from matrix-org/rav/response_cache_wrap
Refactor ResponseCache usage
Diffstat (limited to 'synapse/replication/http')
-rw-r--r-- | synapse/replication/http/send_event.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/synapse/replication/http/send_event.py b/synapse/replication/http/send_event.py index c6a6551d24..a9baa2c1c3 100644 --- a/synapse/replication/http/send_event.py +++ b/synapse/replication/http/send_event.py @@ -23,7 +23,6 @@ from synapse.events.snapshot import EventContext from synapse.http.servlet import RestServlet, parse_json_object_from_request from synapse.util.async import sleep from synapse.util.caches.response_cache import ResponseCache -from synapse.util.logcontext import make_deferred_yieldable, preserve_fn from synapse.util.metrics import Measure from synapse.types import Requester, UserID @@ -118,17 +117,12 @@ class ReplicationSendEventRestServlet(RestServlet): self.response_cache = ResponseCache(hs, "send_event", timeout_ms=30 * 60 * 1000) def on_PUT(self, request, event_id): - result = self.response_cache.get(event_id) - if not result: - result = self.response_cache.set( - event_id, - self._handle_request(request) - ) - else: - logger.warn("Returning cached response") - return make_deferred_yieldable(result) - - @preserve_fn + return self.response_cache.wrap( + event_id, + self._handle_request, + request + ) + @defer.inlineCallbacks def _handle_request(self, request): with Measure(self.clock, "repl_send_event_parse"): |