summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-25 16:59:27 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-25 19:06:05 +0000
commit033a517febc434269eefc75e4d9646d015beae54 (patch)
tree6c1fab8024ea40d072b5e348bdaff794174389d7 /synapse/storage
parentAllow a choice of LRU behaviour for Cache() by using LruCache() or OrderedDict() (diff)
downloadsynapse-033a517febc434269eefc75e4d9646d015beae54.tar.xz
Indirect invalidations of _get_event_cache via a helper method to keep all uses of the cache lexically within one .py file
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/_base.py3
-rw-r--r--synapse/storage/events.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 6fa63f052e..374db1a304 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -732,6 +732,9 @@ class SQLBaseStore(object):
 
         return [e for e in events if e]
 
+    def _invalidate_get_event_cache(self, event_id):
+        self._get_event_cache.pop(event_id)
+
     def _get_event_txn(self, txn, event_id, check_redacted=True,
                        get_prev_content=False, allow_rejected=False):
 
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index a86230d92c..2425f57f5f 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -94,7 +94,7 @@ class EventsStore(SQLBaseStore):
                            current_state=None):
 
         # Remove the any existing cache entries for the event_id
-        self._get_event_cache.pop(event.event_id)
+        self._invalidate_get_event_cache(event.event_id)
 
         # We purposefully do this first since if we include a `current_state`
         # key, we *want* to update the `current_state_events` table
@@ -356,7 +356,7 @@ class EventsStore(SQLBaseStore):
 
     def _store_redaction(self, txn, event):
         # invalidate the cache for the redacted event
-        self._get_event_cache.pop(event.redacts)
+        self._invalidate_get_event_cache(event.redacts)
         txn.execute(
             "INSERT INTO redactions (event_id, redacts) VALUES (?,?)",
             (event.event_id, event.redacts)