Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Remove SnapshotCache in favour of ResponseCache #6506

Merged
merged 2 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6506.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove `SnapshotCache` in favour of `ResponseCache`.
19 changes: 8 additions & 11 deletions synapse/handlers/initial_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from synapse.types import StreamToken, UserID
from synapse.util import unwrapFirstError
from synapse.util.async_helpers import concurrently_execute
from synapse.util.caches.snapshot_cache import SnapshotCache
from synapse.util.caches.response_cache import ResponseCache
from synapse.visibility import filter_events_for_client

from ._base import BaseHandler
Expand All @@ -41,7 +41,7 @@ def __init__(self, hs):
self.state = hs.get_state_handler()
self.clock = hs.get_clock()
self.validator = EventValidator()
self.snapshot_cache = SnapshotCache()
self.snapshot_cache = ResponseCache(hs, "initial_sync_cache")
self._event_serializer = hs.get_event_client_serializer()
self.storage = hs.get_storage()
self.state_store = self.storage.state
Expand Down Expand Up @@ -79,17 +79,14 @@ def snapshot_all_rooms(
as_client_event,
include_archived,
)
now_ms = self.clock.time_msec()
result = self.snapshot_cache.get(now_ms, key)
if result is not None:
return result

return self.snapshot_cache.set(
now_ms,
return self.snapshot_cache.wrap(
key,
self._snapshot_all_rooms(
user_id, pagin_config, as_client_event, include_archived
),
self._snapshot_all_rooms,
user_id,
pagin_config,
as_client_event,
include_archived,
)

@defer.inlineCallbacks
Expand Down
94 changes: 0 additions & 94 deletions synapse/util/caches/snapshot_cache.py

This file was deleted.

63 changes: 0 additions & 63 deletions tests/util/test_snapshot_cache.py

This file was deleted.