mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-18 15:50:52 +01:00
131bedc1a1
* Don't proactively cache event types and state keys when we don't know if the transaction has persisted yet * Remove event type and state key caches altogether
40 lines
988 B
Go
40 lines
988 B
Go
package caching
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
|
)
|
|
|
|
const (
|
|
RoomServerRoomIDsCacheName = "roomserver_room_ids"
|
|
RoomServerRoomIDsCacheMaxEntries = 1024
|
|
RoomServerRoomIDsCacheMutable = false
|
|
)
|
|
|
|
type RoomServerCaches interface {
|
|
RoomServerNIDsCache
|
|
RoomVersionCache
|
|
RoomInfoCache
|
|
}
|
|
|
|
// RoomServerNIDsCache contains the subset of functions needed for
|
|
// a roomserver NID cache.
|
|
type RoomServerNIDsCache interface {
|
|
GetRoomServerRoomID(roomNID types.RoomNID) (string, bool)
|
|
StoreRoomServerRoomID(roomNID types.RoomNID, roomID string)
|
|
}
|
|
|
|
func (c Caches) GetRoomServerRoomID(roomNID types.RoomNID) (string, bool) {
|
|
val, found := c.RoomServerRoomIDs.Get(strconv.Itoa(int(roomNID)))
|
|
if found && val != nil {
|
|
if roomID, ok := val.(string); ok {
|
|
return roomID, true
|
|
}
|
|
}
|
|
return "", false
|
|
}
|
|
|
|
func (c Caches) StoreRoomServerRoomID(roomNID types.RoomNID, roomID string) {
|
|
c.RoomServerRoomIDs.Set(strconv.Itoa(int(roomNID)), roomID)
|
|
}
|