From 45de9dc1c04e544a663e198a1107bcddc5712726 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 21 Sep 2020 16:49:37 +0100 Subject: [PATCH] Use room version cache in Events() --- roomserver/storage/shared/storage.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index e710b99b7..f8e733ab7 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -320,9 +320,14 @@ func (d *Database) Events( if err != nil { return nil, err } - roomVersion, err = d.RoomsTable.SelectRoomVersionForRoomNID(ctx, roomNID) - if err != nil { - return nil, err + if roomID, ok := d.Cache.GetRoomServerRoomID(roomNID); ok { + roomVersion, _ = d.Cache.GetRoomVersion(roomID) + } + if roomVersion == "" { + roomVersion, err = d.RoomsTable.SelectRoomVersionForRoomNID(ctx, roomNID) + if err != nil { + return nil, err + } } result.Event, err = gomatrixserverlib.NewEventFromTrustedJSON( eventJSON.EventJSON, false, roomVersion,