dendrite/internal/caching/cache_lazy_load_members.go
Tak Wai Wong 698369f5d6
merge latest changes from dendrite main (#15)
Co-authored-by: Tak Wai Wong <tak@hntlabs.com>
2022-07-14 14:00:19 -07:00

36 lines
1 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)
}
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,
})
}