diff options
author | Erik Johnston <erik@matrix.org> | 2017-03-03 16:02:53 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2017-03-03 16:02:53 +0000 |
commit | f2581ee8b81e72c49b0c16ca41071c87292c0227 (patch) | |
tree | 99c9e15724830e87a8bc7dcffd6d45e0efc28e6b | |
parent | Spelling (diff) | |
download | synapse-f2581ee8b81e72c49b0c16ca41071c87292c0227.tar.xz |
Don't keep around old stream IDs forever
-rw-r--r-- | synapse/handlers/device.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py index 540b438797..e859b3165f 100644 --- a/synapse/handlers/device.py +++ b/synapse/handlers/device.py @@ -16,6 +16,7 @@ from synapse.api import errors from synapse.api.constants import EventTypes from synapse.util import stringutils from synapse.util.async import Linearizer +from synapse.util.caches.expiringcache import ExpiringCache from synapse.util.metrics import measure_func from synapse.types import get_domain_from_id, RoomStreamToken from twisted.internet import defer @@ -344,7 +345,13 @@ class DeviceListEduUpdater(object): # Recently seen stream ids. We don't bother keeping these in the DB, # but they're useful to have them about to reduce the number of spurious # resyncs. - self._seen_updates = {} + self._seen_updates = ExpiringCache( + cache_name="device_update_edu", + clock=self.clock, + max_len=10000, + expiry_ms=30 * 60 * 1000, + iterable=True, + ) @defer.inlineCallbacks def incoming_device_list_update(self, origin, edu_content): @@ -412,7 +419,7 @@ class DeviceListEduUpdater(object): ) self._seen_updates.setdefault(user_id, set()).update( - [stream_id for _, stream_id, _, _ in pending_updates] + stream_id for _, stream_id, _, _ in pending_updates ) @defer.inlineCallbacks |