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

Commit

Permalink
Merge pull request #6506 from matrix-org/erikj/remove_snapshot_cache
Browse files Browse the repository at this point in the history
Remove SnapshotCache in favour of ResponseCache
  • Loading branch information
erikjohnston authored Dec 10, 2019
2 parents 0f3614f + b1e7012 commit e3f528c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 168 deletions.
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.

0 comments on commit e3f528c

Please sign in to comment.