mirror of
https://github.com/1f349/dendrite.git
synced 2024-12-23 00:34:07 +00:00
ad07b169b8
This PR changes a few things: - It pulls out the creation of several NIDs from the `StoreEvent` function to make the functions more reusable - Uses more caching when using those NIDs to avoid DB round trips
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package caching
|
|
|
|
import (
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
|
)
|
|
|
|
type RoomServerCaches interface {
|
|
RoomServerNIDsCache
|
|
RoomVersionCache
|
|
RoomServerEventsCache
|
|
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)
|
|
}
|