2020-06-05 10:42:01 -05:00
|
|
|
package caching
|
|
|
|
|
|
|
|
import "github.com/matrix-org/gomatrixserverlib"
|
|
|
|
|
|
|
|
const (
|
|
|
|
RoomVersionCacheName = "room_versions"
|
|
|
|
RoomVersionCacheMaxEntries = 1024
|
|
|
|
RoomVersionCacheMutable = false
|
2022-03-01 10:59:52 -06:00
|
|
|
RoomVersionCacheMaxAge = CacheNoMaxAge
|
2020-06-05 10:42:01 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// RoomVersionsCache contains the subset of functions needed for
|
|
|
|
// a room version cache.
|
|
|
|
type RoomVersionCache interface {
|
|
|
|
GetRoomVersion(roomID string) (roomVersion gomatrixserverlib.RoomVersion, ok bool)
|
|
|
|
StoreRoomVersion(roomID string, roomVersion gomatrixserverlib.RoomVersion)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Caches) GetRoomVersion(roomID string) (gomatrixserverlib.RoomVersion, bool) {
|
|
|
|
val, found := c.RoomVersions.Get(roomID)
|
|
|
|
if found && val != nil {
|
|
|
|
if roomVersion, ok := val.(gomatrixserverlib.RoomVersion); ok {
|
|
|
|
return roomVersion, true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "", false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Caches) StoreRoomVersion(roomID string, roomVersion gomatrixserverlib.RoomVersion) {
|
|
|
|
c.RoomVersions.Set(roomID, roomVersion)
|
|
|
|
}
|