summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-08-15 10:21:25 +0100
committerErik Johnston <erik@matrix.org>2016-08-15 11:15:17 +0100
commit4d70d1f80ea688304abdcbbf3ee01f6ab932abc7 (patch)
treeb6389f1bf99d1266fd555c255caa34bed8aaae43 /synapse/storage/_base.py
parentAlways run txn.after_callbacks (diff)
downloadsynapse-4d70d1f80ea688304abdcbbf3ee01f6ab932abc7.tar.xz
Add some invalidations to a cache_stream
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r--synapse/storage/_base.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index e516b6de3e..02d9098ddd 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -861,6 +861,24 @@ class SQLBaseStore(object):
 
         return cache, min_val
 
+    def _invalidate_cache_and_stream(self, txn, cache_func, keys):
+        txn.call_after(cache_func.invalidate, keys)
+
+        ctx = self._cache_id_gen.get_next()
+        stream_id = ctx.__enter__()
+        txn.call_after(ctx.__exit__, None, None, None)
+
+        self._simple_insert_txn(
+            txn,
+            table="cache_stream",
+            values={
+                "stream_id": stream_id,
+                "cache_func": cache_func.__name__,
+                "keys": list(keys),
+                "invalidation_ts": self.clock.time_msec(),
+            }
+        )
+
 
 class _RollbackButIsFineException(Exception):
     """ This exception is used to rollback a transaction without implying