summary refs log tree commit diff
path: root/synapse/module_api/__init__.py
diff options
context:
space:
mode:
authorMathieu Velten <mathieuv@matrix.org>2022-08-11 14:26:40 +0200
committerMathieu Velten <mathieuv@matrix.org>2022-08-12 16:20:26 +0200
commit941ab4b483e24997106e2478e37057450c4f9c14 (patch)
treeb583812cce5c928935e234e52e5910ea36de0a68 /synapse/module_api/__init__.py
parentAdd test for account validity feature (diff)
downloadsynapse-github/mv/test-account-validity.tar.xz
Add cache invalidation to module API github/mv/test-account-validity mv/test-account-validity
Diffstat (limited to 'synapse/module_api/__init__.py')
-rw-r--r--synapse/module_api/__init__.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py

index 87ba154cb7..19b501c9e3 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py
@@ -125,7 +125,7 @@ from synapse.types import ( ) from synapse.util import Clock from synapse.util.async_helpers import maybe_awaitable -from synapse.util.caches.descriptors import cached +from synapse.util.caches.descriptors import CachedFunction, cached from synapse.util.frozenutils import freeze if TYPE_CHECKING: @@ -836,6 +836,20 @@ class ModuleApi: self._store.db_pool.runInteraction(desc, func, *args, **kwargs) # type: ignore[arg-type] ) + async def invalidate_cache( + self, cached_func: CachedFunction, keys: Tuple[Any, ...] + ) -> None: + cached_func.invalidate(keys) + await self._store.send_invalidation_to_replication( + cached_func.__qualname__, + keys, + ) + + def register_cached_function(self, cached_func: CachedFunction) -> None: + self._store.register_external_cached_function( + cached_func.__qualname__, cached_func + ) + def complete_sso_login( self, registered_user_id: str, request: SynapseRequest, client_redirect_url: str ) -> None: