diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-11-09 14:40:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-09 14:40:30 -0500 |
commit | 9f514dd0fbf539d97b6d9f8f590aaf668fb3280e (patch) | |
tree | 80463e04fdef771952a8b5712b6a944c9660a5f2 /synapse/storage/databases/main/registration.py | |
parent | Convert simple_select_one_txn and simple_select_one to return tuples. (#16612) (diff) | |
download | synapse-9f514dd0fbf539d97b6d9f8f590aaf668fb3280e.tar.xz |
Use _invalidate_cache_and_stream_bulk in more places. (#16616)
This takes advantage of the new bulk method in more places to invalidate caches for many keys at once (and then to stream that over replication).
Diffstat (limited to 'synapse/storage/databases/main/registration.py')
-rw-r--r-- | synapse/storage/databases/main/registration.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/synapse/storage/databases/main/registration.py b/synapse/storage/databases/main/registration.py index dec9858575..2c3f30e2eb 100644 --- a/synapse/storage/databases/main/registration.py +++ b/synapse/storage/databases/main/registration.py @@ -561,16 +561,15 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore): updatevalues={"shadow_banned": shadow_banned}, ) # In order for this to apply immediately, clear the cache for this user. - tokens = self.db_pool.simple_select_onecol_txn( + tokens = self.db_pool.simple_select_list_txn( txn, table="access_tokens", keyvalues={"user_id": user_id}, - retcol="token", + retcols=("token",), + ) + self._invalidate_cache_and_stream_bulk( + txn, self.get_user_by_access_token, tokens ) - for token in tokens: - self._invalidate_cache_and_stream( - txn, self.get_user_by_access_token, (token,) - ) self._invalidate_cache_and_stream(txn, self.get_user_by_id, (user_id,)) await self.db_pool.runInteraction("set_shadow_banned", set_shadow_banned_txn) @@ -2683,10 +2682,11 @@ class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore): ) tokens_and_devices = [(r[0], r[1], r[2]) for r in txn] - for token, _, _ in tokens_and_devices: - self._invalidate_cache_and_stream( - txn, self.get_user_by_access_token, (token,) - ) + self._invalidate_cache_and_stream_bulk( + txn, + self.get_user_by_access_token, + [(token,) for token, _, _ in tokens_and_devices], + ) txn.execute("DELETE FROM access_tokens WHERE %s" % where_clause, values) |