mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-18 07:40:53 +01:00
3a156a434a
* Bypass lazyLoadCache if we're doing an initial sync
* Make the linter happy again?
* Revert "Make the linter happy again?"
This reverts commit 52a5691ba3
.
* Try that again
* Invalidate LazyLoadCache on initial syncs
* Remove unneeded check
* Add TODO
* Rename Invalite -> InvalidateLazyLoadedUser
* Thanks IDE
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package caching
|
|
|
|
import (
|
|
userapi "github.com/matrix-org/dendrite/userapi/api"
|
|
)
|
|
|
|
type lazyLoadingCacheKey struct {
|
|
UserID string // the user we're querying on behalf of
|
|
DeviceID string // the user we're querying on behalf of
|
|
RoomID string // the room in question
|
|
TargetUserID string // the user whose membership we're asking about
|
|
}
|
|
|
|
type LazyLoadCache interface {
|
|
StoreLazyLoadedUser(device *userapi.Device, roomID, userID, eventID string)
|
|
IsLazyLoadedUserCached(device *userapi.Device, roomID, userID string) (string, bool)
|
|
InvalidateLazyLoadedUser(device *userapi.Device, roomID, userID string)
|
|
}
|
|
|
|
func (c Caches) StoreLazyLoadedUser(device *userapi.Device, roomID, userID, eventID string) {
|
|
c.LazyLoading.Set(lazyLoadingCacheKey{
|
|
UserID: device.UserID,
|
|
DeviceID: device.ID,
|
|
RoomID: roomID,
|
|
TargetUserID: userID,
|
|
}, eventID)
|
|
}
|
|
|
|
func (c Caches) IsLazyLoadedUserCached(device *userapi.Device, roomID, userID string) (string, bool) {
|
|
return c.LazyLoading.Get(lazyLoadingCacheKey{
|
|
UserID: device.UserID,
|
|
DeviceID: device.ID,
|
|
RoomID: roomID,
|
|
TargetUserID: userID,
|
|
})
|
|
}
|
|
|
|
func (c Caches) InvalidateLazyLoadedUser(device *userapi.Device, roomID, userID string) {
|
|
c.LazyLoading.Unset(lazyLoadingCacheKey{
|
|
UserID: device.UserID,
|
|
DeviceID: device.ID,
|
|
RoomID: roomID,
|
|
TargetUserID: userID,
|
|
})
|
|
}
|