Populate caches

This commit is contained in:
Neil Alexander 2020-08-25 11:18:46 +01:00
parent 38547192d7
commit ede9da20dd
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -69,6 +69,7 @@ func (d *Database) EventTypeNIDs(
}
for eventType, nid := range nids {
result[eventType] = nid
d.Cache.StoreRoomServerEventTypeNID(eventType, nid)
}
}
return result, nil
@ -99,6 +100,7 @@ func (d *Database) EventStateKeyNIDs(
}
for eventStateKey, nid := range nids {
result[eventStateKey] = nid
d.Cache.StoreRoomServerStateKeyNID(eventStateKey, nid)
}
}
return result, nil
@ -202,6 +204,7 @@ func (d *Database) RoomNID(ctx context.Context, roomID string) (types.RoomNID, e
if err == sql.ErrNoRows {
return 0, nil
}
d.Cache.StoreRoomServerRoomNID(roomID, roomNID)
return roomNID, err
}
@ -213,6 +216,7 @@ func (d *Database) RoomNIDExcludingStubs(ctx context.Context, roomID string) (ro
if err != nil {
return
}
d.Cache.StoreRoomServerRoomNID(roomID, roomNID)
}
latestEvents, _, err := d.RoomsTable.SelectLatestEventNIDs(ctx, nil, roomNID)
if err != nil {