dendrite/internal/caching/cache_roomevents.go
Till 70322699ab
Unset RoomServerEvent, since we can't be sure that Set actually updates the cached entry (#3002)
This should deflake UTs and be more correct in terms of getting
`Events`.
`Events` tries to fetch the event from the cache first and may get an
unredacted event from it, while it should already be redacted.
2023-03-09 09:52:13 +01:00

26 lines
879 B
Go

package caching
import (
"github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/gomatrixserverlib"
)
// RoomServerEventsCache contains the subset of functions needed for
// a roomserver event cache.
type RoomServerEventsCache interface {
GetRoomServerEvent(eventNID types.EventNID) (*gomatrixserverlib.Event, bool)
StoreRoomServerEvent(eventNID types.EventNID, event *gomatrixserverlib.Event)
InvalidateRoomServerEvent(eventNID types.EventNID)
}
func (c Caches) GetRoomServerEvent(eventNID types.EventNID) (*gomatrixserverlib.Event, bool) {
return c.RoomServerEvents.Get(int64(eventNID))
}
func (c Caches) StoreRoomServerEvent(eventNID types.EventNID, event *gomatrixserverlib.Event) {
c.RoomServerEvents.Set(int64(eventNID), event)
}
func (c Caches) InvalidateRoomServerEvent(eventNID types.EventNID) {
c.RoomServerEvents.Unset(int64(eventNID))
}