mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 01:59:21 -05:00
Switch over /events to use per room caches
This commit is contained in:
parent
2d3837bec7
commit
4bf448be25
@ -1008,15 +1008,30 @@ class RoomEventSource(object):
|
||||
limit=limit,
|
||||
)
|
||||
else:
|
||||
events, end_key = yield self.store.get_room_events_stream(
|
||||
user_id=user.to_string(),
|
||||
room_events = yield self.store.get_room_changes_for_user(
|
||||
user.to_string(), from_key, to_key
|
||||
)
|
||||
|
||||
room_to_events = yield self.store.get_room_events_stream_for_rooms(
|
||||
room_ids=room_ids,
|
||||
from_key=from_key,
|
||||
to_key=to_key,
|
||||
limit=limit,
|
||||
room_ids=room_ids,
|
||||
is_guest=is_guest,
|
||||
limit=limit or 10,
|
||||
)
|
||||
|
||||
events = list(room_events)
|
||||
events.extend(e for evs, _ in room_to_events.values() for e in evs)
|
||||
|
||||
events.sort(key=lambda e: e.internal_metadata.after)
|
||||
|
||||
if limit:
|
||||
events[:] = events[:limit]
|
||||
|
||||
if events:
|
||||
end_key = events[-1].internal_metadata.after
|
||||
else:
|
||||
end_key = to_key
|
||||
|
||||
defer.returnValue((events, end_key))
|
||||
|
||||
def get_current_key(self, direction='f'):
|
||||
|
@ -39,7 +39,6 @@ from ._base import SQLBaseStore
|
||||
from synapse.util.caches.descriptors import cachedInlineCallbacks
|
||||
from synapse.api.constants import EventTypes
|
||||
from synapse.types import RoomStreamToken
|
||||
from synapse.util.logutils import log_function
|
||||
|
||||
import logging
|
||||
|
||||
@ -288,11 +287,12 @@ class StreamStore(SQLBaseStore):
|
||||
get_prev_content=True
|
||||
)
|
||||
|
||||
self._set_before_and_after(ret, rows, topo_order=False)
|
||||
|
||||
return ret
|
||||
|
||||
return self.runInteraction("get_room_changes_for_user", f)
|
||||
|
||||
@log_function
|
||||
def get_room_events_stream(
|
||||
self,
|
||||
user_id,
|
||||
|
Loading…
Reference in New Issue
Block a user