diff options
author | Erik Johnston <erik@matrix.org> | 2016-06-29 11:41:20 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-06-29 11:41:20 +0100 |
commit | 314b146b2e3082fc6bc61296f5c2ea5d7735f01e (patch) | |
tree | 0b0f52cadd84d4b7c8f32505183fbadac7d56fd1 /synapse/storage/media_repository.py | |
parent | Merge pull request #900 from RickCogley/RickCogley-coturn-readme-2 (diff) | |
download | synapse-314b146b2e3082fc6bc61296f5c2ea5d7735f01e.tar.xz |
Track approximate last access time for remote media
Diffstat (limited to 'synapse/storage/media_repository.py')
-rw-r--r-- | synapse/storage/media_repository.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/storage/media_repository.py b/synapse/storage/media_repository.py index a820fcf07f..44e4d38307 100644 --- a/synapse/storage/media_repository.py +++ b/synapse/storage/media_repository.py @@ -157,10 +157,25 @@ class MediaRepositoryStore(SQLBaseStore): "created_ts": time_now_ms, "upload_name": upload_name, "filesystem_id": filesystem_id, + "last_access_ts": time_now_ms, }, desc="store_cached_remote_media", ) + def update_cached_last_access_time(self, origin_id_tuples, time_ts): + def update_cache_txn(txn): + sql = ( + "UPDATE remote_media_cache SET last_access_ts = ?" + " WHERE media_origin = ? AND media_id = ?" + ) + + txn.executemany(sql, ( + (time_ts, media_origin, media_id) + for media_origin, media_id in origin_id_tuples + )) + + return self.runInteraction("update_cached_last_access_time", update_cache_txn) + def get_remote_media_thumbnails(self, origin, media_id): return self._simple_select_list( "remote_media_cache_thumbnails", |