diff options
author | Erik Johnston <erik@matrix.org> | 2024-05-16 16:08:39 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2024-05-16 16:08:39 +0100 |
commit | 12a4094a5f44104fb61451245eed00a2015e083d (patch) | |
tree | f0ff02d3bff306a7f79a8efa07bfbaad388f170d /synapse/storage | |
parent | Merge remote-tracking branch 'origin/develop' into matrix-org-hotfixes (diff) | |
parent | Revert "Improve perf of sync device lists" (#17207) (diff) | |
download | synapse-12a4094a5f44104fb61451245eed00a2015e083d.tar.xz |
Merge remote-tracking branch 'origin/develop' into matrix-org-hotfixes
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/databases/main/devices.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/synapse/storage/databases/main/devices.py b/synapse/storage/databases/main/devices.py index 4b8e55dd2e..0330b8a0f5 100644 --- a/synapse/storage/databases/main/devices.py +++ b/synapse/storage/databases/main/devices.py @@ -70,7 +70,10 @@ from synapse.types import ( from synapse.util import json_decoder, json_encoder from synapse.util.caches.descriptors import cached, cachedList from synapse.util.caches.lrucache import LruCache -from synapse.util.caches.stream_change_cache import StreamChangeCache +from synapse.util.caches.stream_change_cache import ( + AllEntitiesChangedResult, + StreamChangeCache, +) from synapse.util.cancellation import cancellable from synapse.util.iterutils import batch_iter from synapse.util.stringutils import shortstr @@ -831,6 +834,16 @@ class DeviceWorkerStore(RoomMemberWorkerStore, EndToEndKeyWorkerStore): ) return {device[0]: db_to_json(device[1]) for device in devices} + def get_cached_device_list_changes( + self, + from_key: int, + ) -> AllEntitiesChangedResult: + """Get set of users whose devices have changed since `from_key`, or None + if that information is not in our cache. + """ + + return self._device_list_stream_cache.get_all_entities_changed(from_key) + @cancellable async def get_all_devices_changed( self, @@ -1464,7 +1477,7 @@ class DeviceWorkerStore(RoomMemberWorkerStore, EndToEndKeyWorkerStore): sql = """ SELECT DISTINCT user_id FROM device_lists_changes_in_room - WHERE {clause} AND stream_id > ? + WHERE {clause} AND stream_id >= ? """ def _get_device_list_changes_in_rooms_txn( |