mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
Move LL cache (#2429)
This commit is contained in:
parent
507f63d0fc
commit
6493c0c0f2
9 changed files with 34 additions and 41 deletions
|
@ -45,7 +45,7 @@ func Context(
|
|||
rsAPI roomserver.SyncRoomserverAPI,
|
||||
syncDB storage.Database,
|
||||
roomID, eventID string,
|
||||
lazyLoadCache *caching.LazyLoadCache,
|
||||
lazyLoadCache caching.LazyLoadCache,
|
||||
) util.JSONResponse {
|
||||
filter, err := parseRoomEventFilter(req)
|
||||
if err != nil {
|
||||
|
@ -155,7 +155,7 @@ func applyLazyLoadMembers(
|
|||
filter *gomatrixserverlib.RoomEventFilter,
|
||||
eventsAfter, eventsBefore []gomatrixserverlib.ClientEvent,
|
||||
state []*gomatrixserverlib.HeaderedEvent,
|
||||
lazyLoadCache *caching.LazyLoadCache,
|
||||
lazyLoadCache caching.LazyLoadCache,
|
||||
) []*gomatrixserverlib.HeaderedEvent {
|
||||
if filter == nil || !filter.LazyLoadMembers {
|
||||
return state
|
||||
|
|
|
@ -63,7 +63,7 @@ func OnIncomingMessagesRequest(
|
|||
rsAPI api.SyncRoomserverAPI,
|
||||
cfg *config.SyncAPI,
|
||||
srp *sync.RequestPool,
|
||||
lazyLoadCache *caching.LazyLoadCache,
|
||||
lazyLoadCache caching.LazyLoadCache,
|
||||
) util.JSONResponse {
|
||||
var err error
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ func Setup(
|
|||
userAPI userapi.SyncUserAPI,
|
||||
rsAPI api.SyncRoomserverAPI,
|
||||
cfg *config.SyncAPI,
|
||||
lazyLoadCache *caching.LazyLoadCache,
|
||||
lazyLoadCache caching.LazyLoadCache,
|
||||
) {
|
||||
v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter()
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ type PDUStreamProvider struct {
|
|||
tasks chan func()
|
||||
workers atomic.Int32
|
||||
// userID+deviceID -> lazy loading cache
|
||||
lazyLoadCache *caching.LazyLoadCache
|
||||
lazyLoadCache caching.LazyLoadCache
|
||||
rsAPI roomserverAPI.SyncRoomserverAPI
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ type Streams struct {
|
|||
func NewSyncStreamProviders(
|
||||
d storage.Database, userAPI userapi.SyncUserAPI,
|
||||
rsAPI rsapi.SyncRoomserverAPI, keyAPI keyapi.SyncKeyAPI,
|
||||
eduCache *caching.EDUCache, lazyLoadCache *caching.LazyLoadCache, notifier *notifier.Notifier,
|
||||
eduCache *caching.EDUCache, lazyLoadCache caching.LazyLoadCache, notifier *notifier.Notifier,
|
||||
) *Streams {
|
||||
streams := &Streams{
|
||||
PDUStreamProvider: &PDUStreamProvider{
|
||||
|
|
|
@ -53,12 +53,8 @@ func AddPublicRoutes(
|
|||
}
|
||||
|
||||
eduCache := caching.NewTypingCache()
|
||||
lazyLoadCache, err := caching.NewLazyLoadCache()
|
||||
if err != nil {
|
||||
logrus.WithError(err).Panicf("failed to create lazy loading cache")
|
||||
}
|
||||
notifier := notifier.NewNotifier()
|
||||
streams := streams.NewSyncStreamProviders(syncDB, userAPI, rsAPI, keyAPI, eduCache, lazyLoadCache, notifier)
|
||||
streams := streams.NewSyncStreamProviders(syncDB, userAPI, rsAPI, keyAPI, eduCache, base.Caches, notifier)
|
||||
notifier.SetCurrentPosition(streams.Latest(context.Background()))
|
||||
if err = notifier.Load(context.Background(), syncDB); err != nil {
|
||||
logrus.WithError(err).Panicf("failed to load notifier ")
|
||||
|
@ -146,6 +142,6 @@ func AddPublicRoutes(
|
|||
|
||||
routing.Setup(
|
||||
base.PublicClientAPIMux, requestPool, syncDB, userAPI,
|
||||
rsAPI, cfg, lazyLoadCache,
|
||||
rsAPI, cfg, base.Caches,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue