summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/9950.feature1
-rw-r--r--synapse/handlers/message.py13
2 files changed, 8 insertions, 6 deletions
diff --git a/changelog.d/9950.feature b/changelog.d/9950.feature
new file mode 100644
index 0000000000..96a0e7f09f
--- /dev/null
+++ b/changelog.d/9950.feature
@@ -0,0 +1 @@
+Improve performance of sending events for worker-based deployments using Redis.
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 8729332d4b..5afb7fc261 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -1050,6 +1050,13 @@ class EventCreationHandler:
         )
 
         if state_entry.state_group:
+            await self._external_cache.set(
+                "event_to_prev_state_group",
+                event.event_id,
+                state_entry.state_group,
+                expiry_ms=60 * 60 * 1000,
+            )
+
             if state_entry.state_group in self._external_cache_joined_hosts_updates:
                 return
 
@@ -1058,12 +1065,6 @@ class EventCreationHandler:
             # Note that the expiry times must be larger than the expiry time in
             # _external_cache_joined_hosts_updates.
             await self._external_cache.set(
-                "event_to_prev_state_group",
-                event.event_id,
-                state_entry.state_group,
-                expiry_ms=60 * 60 * 1000,
-            )
-            await self._external_cache.set(
                 "get_joined_hosts",
                 str(state_entry.state_group),
                 list(joined_hosts),