summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-03-23 13:25:30 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-03-23 13:25:30 +0000
commitc83cd65ddd86b00e5e85b5fad759f22d28d54f8a (patch)
tree70dc524197328171cb35de0d99b4b4984f73346c /synapse/storage
parentMerge pull request #6775 from matrix-org/jaywink/worker-docs-tweaks (diff)
parentPropagate cache invalidates from workers to other workers. (#6748) (diff)
downloadsynapse-c83cd65ddd86b00e5e85b5fad759f22d28d54f8a.tar.xz
Propagate cache invalidates from workers to other workers. (#6748)
* commit 'd5275fc55':
  Propagate cache invalidates from workers to other workers. (#6748)
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/data_stores/main/cache.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/synapse/storage/data_stores/main/cache.py b/synapse/storage/data_stores/main/cache.py

index afa2b41c98..d4c44dcc75 100644 --- a/synapse/storage/data_stores/main/cache.py +++ b/synapse/storage/data_stores/main/cache.py
@@ -16,7 +16,7 @@ import itertools import logging -from typing import Any, Iterable, Optional +from typing import Any, Iterable, Optional, Tuple from twisted.internet import defer @@ -33,6 +33,26 @@ CURRENT_STATE_CACHE_NAME = "cs_cache_fake" class CacheInvalidationStore(SQLBaseStore): + async def invalidate_cache_and_stream(self, cache_name: str, keys: Tuple[Any, ...]): + """Invalidates the cache and adds it to the cache stream so slaves + will know to invalidate their caches. + + This should only be used to invalidate caches where slaves won't + otherwise know from other replication streams that the cache should + be invalidated. + """ + cache_func = getattr(self, cache_name, None) + if not cache_func: + return + + cache_func.invalidate(keys) + await self.runInteraction( + "invalidate_cache_and_stream", + self._send_invalidation_to_replication, + cache_func.__name__, + keys, + ) + def _invalidate_cache_and_stream(self, txn, cache_func, keys): """Invalidates the cache and adds it to the cache stream so slaves will know to invalidate their caches.