2020-08-25 06:32:29 -05:00
|
|
|
package caching
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RoomServerCaches interface {
|
|
|
|
RoomServerNIDsCache
|
|
|
|
RoomVersionCache
|
2022-07-11 08:31:31 -05:00
|
|
|
RoomServerEventsCache
|
2023-07-20 09:06:05 -05:00
|
|
|
RoomHierarchyCache
|
2022-07-19 06:15:48 -05:00
|
|
|
EventStateKeyCache
|
2023-02-24 02:40:20 -06:00
|
|
|
EventTypeCache
|
2020-08-25 06:32:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// RoomServerNIDsCache contains the subset of functions needed for
|
|
|
|
// a roomserver NID cache.
|
|
|
|
type RoomServerNIDsCache interface {
|
|
|
|
GetRoomServerRoomID(roomNID types.RoomNID) (string, bool)
|
2023-02-24 02:40:20 -06:00
|
|
|
// StoreRoomServerRoomID stores roomNID -> roomID and roomID -> roomNID
|
2020-08-25 06:32:29 -05:00
|
|
|
StoreRoomServerRoomID(roomNID types.RoomNID, roomID string)
|
2023-02-24 02:40:20 -06:00
|
|
|
GetRoomServerRoomNID(roomID string) (types.RoomNID, bool)
|
2020-08-25 06:32:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c Caches) GetRoomServerRoomID(roomNID types.RoomNID) (string, bool) {
|
2022-07-19 06:15:48 -05:00
|
|
|
return c.RoomServerRoomIDs.Get(roomNID)
|
2020-08-25 06:32:29 -05:00
|
|
|
}
|
|
|
|
|
2023-02-24 02:40:20 -06:00
|
|
|
// StoreRoomServerRoomID stores roomNID -> roomID and roomID -> roomNID
|
2020-08-25 06:32:29 -05:00
|
|
|
func (c Caches) StoreRoomServerRoomID(roomNID types.RoomNID, roomID string) {
|
2023-02-24 02:40:20 -06:00
|
|
|
c.RoomServerRoomNIDs.Set(roomID, roomNID)
|
2022-07-19 06:15:48 -05:00
|
|
|
c.RoomServerRoomIDs.Set(roomNID, roomID)
|
2020-08-25 06:32:29 -05:00
|
|
|
}
|
2023-02-24 02:40:20 -06:00
|
|
|
|
|
|
|
func (c Caches) GetRoomServerRoomNID(roomID string) (types.RoomNID, bool) {
|
|
|
|
return c.RoomServerRoomNIDs.Get(roomID)
|
|
|
|
}
|