mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-29 17:51:56 -06:00
9582827493
- This PR moves and refactors the [code](https://github.com/matrix-org/dendrite/blob/main/setup/mscs/msc2946/msc2946.go) for [MSC2946](https://github.com/matrix-org/matrix-spec-proposals/pull/2946) ('Space Summaries') to integrate it into the rest of the codebase. - Means space summaries are no longer hidden behind an MSC flag - Solves #3096 Signed-off-by: Sam Wedgwood <sam@wedgwood.dev>
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package caching
|
|
|
|
import (
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
|
)
|
|
|
|
type RoomServerCaches interface {
|
|
RoomServerNIDsCache
|
|
RoomVersionCache
|
|
RoomServerEventsCache
|
|
RoomHierarchyCache
|
|
EventStateKeyCache
|
|
EventTypeCache
|
|
}
|
|
|
|
// RoomServerNIDsCache contains the subset of functions needed for
|
|
// a roomserver NID cache.
|
|
type RoomServerNIDsCache interface {
|
|
GetRoomServerRoomID(roomNID types.RoomNID) (string, bool)
|
|
// StoreRoomServerRoomID stores roomNID -> roomID and roomID -> roomNID
|
|
StoreRoomServerRoomID(roomNID types.RoomNID, roomID string)
|
|
GetRoomServerRoomNID(roomID string) (types.RoomNID, bool)
|
|
}
|
|
|
|
func (c Caches) GetRoomServerRoomID(roomNID types.RoomNID) (string, bool) {
|
|
return c.RoomServerRoomIDs.Get(roomNID)
|
|
}
|
|
|
|
// StoreRoomServerRoomID stores roomNID -> roomID and roomID -> roomNID
|
|
func (c Caches) StoreRoomServerRoomID(roomNID types.RoomNID, roomID string) {
|
|
c.RoomServerRoomNIDs.Set(roomID, roomNID)
|
|
c.RoomServerRoomIDs.Set(roomNID, roomID)
|
|
}
|
|
|
|
func (c Caches) GetRoomServerRoomNID(roomID string) (types.RoomNID, bool) {
|
|
return c.RoomServerRoomNIDs.Get(roomID)
|
|
}
|