summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-25 17:33:26 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-25 19:06:05 +0000
commitf173d40a32cba919e088917fe42ac300a10e0ad2 (patch)
treecebf04d653455e4664ea583cce57b3b27963842b /synapse
parentStore the rejected reason in (Frozen)Event structs (diff)
downloadsynapse-f173d40a32cba919e088917fe42ac300a10e0ad2.tar.xz
Use FrozenEvent's reject_reason to decide whether to return it; don't include allow_rejected in the main getEvents cache key
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/_base.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 7f5ad9b0fb..919295eabb 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -749,10 +749,13 @@ class SQLBaseStore(object):
 
         try:
             # Separate cache entries for each way to invoke _get_event_txn
-            ret = cache[(check_redacted, get_prev_content, allow_rejected)]
-
+            ret = cache[(check_redacted, get_prev_content)]
             cache_counter.inc_hits("*getEvent*")
-            return ret
+
+            if allow_rejected or not ret.rejected_reason:
+                return ret
+            else:
+                return None
         except KeyError:
             cache_counter.inc_misses("*getEvent*")
             pass
@@ -779,14 +782,15 @@ class SQLBaseStore(object):
 
         start_time = update_counter("select_event", start_time)
 
+        result = self._get_event_from_row_txn(
+            txn, internal_metadata, js, redacted,
+            check_redacted=check_redacted,
+            get_prev_content=get_prev_content,
+            rejected_reason=rejected_reason,
+        )
+        cache[(check_redacted, get_prev_content)] = result
+
         if allow_rejected or not rejected_reason:
-            result = self._get_event_from_row_txn(
-                txn, internal_metadata, js, redacted,
-                check_redacted=check_redacted,
-                get_prev_content=get_prev_content,
-                rejected_reason=rejected_reason,
-            )
-            cache[(check_redacted, get_prev_content, allow_rejected)] = result
             return result
         else:
             return None