diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-09-21 16:49:37 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-09-21 16:49:37 +0100 |
commit | 45de9dc1c04e544a663e198a1107bcddc5712726 (patch) | |
tree | ec81ffbc78939182639c74381d58eab8740277a1 /roomserver/storage | |
parent | a06c18bb562749db1a175a6295e995ec877f1c92 (diff) |
Use room version cache in Events()
Diffstat (limited to 'roomserver/storage')
-rw-r--r-- | roomserver/storage/shared/storage.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index e710b99b..f8e733ab 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, |