mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 14:12:47 +00:00
Remove event type and state key caches (#2200)
* 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
This commit is contained in:
parent
e1eb5807b6
commit
131bedc1a1
4 changed files with 22 additions and 121 deletions
|
@ -7,14 +7,6 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
RoomServerStateKeyNIDsCacheName = "roomserver_statekey_nids"
|
||||
RoomServerStateKeyNIDsCacheMaxEntries = 1024
|
||||
RoomServerStateKeyNIDsCacheMutable = false
|
||||
|
||||
RoomServerEventTypeNIDsCacheName = "roomserver_eventtype_nids"
|
||||
RoomServerEventTypeNIDsCacheMaxEntries = 64
|
||||
RoomServerEventTypeNIDsCacheMutable = false
|
||||
|
||||
RoomServerRoomIDsCacheName = "roomserver_room_ids"
|
||||
RoomServerRoomIDsCacheMaxEntries = 1024
|
||||
RoomServerRoomIDsCacheMutable = false
|
||||
|
@ -29,44 +21,10 @@ type RoomServerCaches interface {
|
|||
// RoomServerNIDsCache contains the subset of functions needed for
|
||||
// a roomserver NID cache.
|
||||
type RoomServerNIDsCache interface {
|
||||
GetRoomServerStateKeyNID(stateKey string) (types.EventStateKeyNID, bool)
|
||||
StoreRoomServerStateKeyNID(stateKey string, nid types.EventStateKeyNID)
|
||||
|
||||
GetRoomServerEventTypeNID(eventType string) (types.EventTypeNID, bool)
|
||||
StoreRoomServerEventTypeNID(eventType string, nid types.EventTypeNID)
|
||||
|
||||
GetRoomServerRoomID(roomNID types.RoomNID) (string, bool)
|
||||
StoreRoomServerRoomID(roomNID types.RoomNID, roomID string)
|
||||
}
|
||||
|
||||
func (c Caches) GetRoomServerStateKeyNID(stateKey string) (types.EventStateKeyNID, bool) {
|
||||
val, found := c.RoomServerStateKeyNIDs.Get(stateKey)
|
||||
if found && val != nil {
|
||||
if stateKeyNID, ok := val.(types.EventStateKeyNID); ok {
|
||||
return stateKeyNID, true
|
||||
}
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (c Caches) StoreRoomServerStateKeyNID(stateKey string, nid types.EventStateKeyNID) {
|
||||
c.RoomServerStateKeyNIDs.Set(stateKey, nid)
|
||||
}
|
||||
|
||||
func (c Caches) GetRoomServerEventTypeNID(eventType string) (types.EventTypeNID, bool) {
|
||||
val, found := c.RoomServerEventTypeNIDs.Get(eventType)
|
||||
if found && val != nil {
|
||||
if eventTypeNID, ok := val.(types.EventTypeNID); ok {
|
||||
return eventTypeNID, true
|
||||
}
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (c Caches) StoreRoomServerEventTypeNID(eventType string, nid types.EventTypeNID) {
|
||||
c.RoomServerEventTypeNIDs.Set(eventType, nid)
|
||||
}
|
||||
|
||||
func (c Caches) GetRoomServerRoomID(roomNID types.RoomNID) (string, bool) {
|
||||
val, found := c.RoomServerRoomIDs.Get(strconv.Itoa(int(roomNID)))
|
||||
if found && val != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue