Refactor StoreEvent and create a new RoomDatabase interface (#2985)
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
This commit is contained in:
parent
e6aa0955ff
commit
ad07b169b8
31 changed files with 459 additions and 302 deletions
|
|
@ -9,19 +9,28 @@ type RoomServerCaches interface {
|
|||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue