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

Commit 3f5d899

Browse files
committed
Move events and membership stream caches into the EventsWorkerStore
1 parent c0318af commit 3f5d899

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

synapse/storage/databases/main/events_worker.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,22 @@ def __init__(
251251
prefilled_cache=curr_state_delta_prefill,
252252
)
253253

254+
event_cache_prefill, min_event_val = self.db_pool.get_cache_dict(
255+
db_conn,
256+
"events",
257+
entity_column="room_id",
258+
stream_column="stream_ordering",
259+
max_value=events_max,
260+
)
261+
self._events_stream_cache = StreamChangeCache(
262+
"EventsRoomStreamChangeCache",
263+
min_event_val,
264+
prefilled_cache=event_cache_prefill,
265+
)
266+
self._membership_stream_cache = StreamChangeCache(
267+
"MembershipStreamChangeCache", events_max
268+
)
269+
254270
if hs.config.worker.run_background_tasks:
255271
# We periodically clean out old transaction ID mappings
256272
self._clock.looping_call(

synapse/storage/databases/main/stream.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
from synapse.storage.util.id_generators import MultiWriterIdGenerator
7272
from synapse.types import PersistedEventPosition, RoomStreamToken
7373
from synapse.util.caches.descriptors import cached
74-
from synapse.util.caches.stream_change_cache import StreamChangeCache
7574
from synapse.util.cancellation import cancellable
7675

7776
if TYPE_CHECKING:
@@ -397,23 +396,6 @@ def __init__(
397396
# during startup which would cause one to die.
398397
self._need_to_reset_federation_stream_positions = self._send_federation
399398

400-
events_max = self.get_room_max_stream_ordering()
401-
event_cache_prefill, min_event_val = self.db_pool.get_cache_dict(
402-
db_conn,
403-
"events",
404-
entity_column="room_id",
405-
stream_column="stream_ordering",
406-
max_value=events_max,
407-
)
408-
self._events_stream_cache = StreamChangeCache(
409-
"EventsRoomStreamChangeCache",
410-
min_event_val,
411-
prefilled_cache=event_cache_prefill,
412-
)
413-
self._membership_stream_cache = StreamChangeCache(
414-
"MembershipStreamChangeCache", events_max
415-
)
416-
417399
self._stream_order_on_start = self.get_room_max_stream_ordering()
418400
self._min_stream_order_on_start = self.get_room_min_stream_ordering()
419401

0 commit comments

Comments
 (0)