mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 14:12:47 +00:00
Roomserver NID caches (#1335)
* Initial work on roomserver NID caches * Give caches to roomserver storage * Populate caches * Fix bugs * Fix WASM build * Don't hit cache twice in RoomNIDExcludingStubs * Store reverse room ID-room NID mapping, consult caches when assigning NIDs
This commit is contained in:
parent
05242096a1
commit
c8b873abc8
10 changed files with 239 additions and 18 deletions
|
@ -19,18 +19,19 @@ package storage
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal/caching"
|
||||
"github.com/matrix-org/dendrite/internal/config"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage/postgres"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage/sqlite3"
|
||||
)
|
||||
|
||||
// Open opens a database connection.
|
||||
func Open(dbProperties *config.DatabaseOptions) (Database, error) {
|
||||
func Open(dbProperties *config.DatabaseOptions, cache caching.RoomServerCaches) (Database, error) {
|
||||
switch {
|
||||
case dbProperties.ConnectionString.IsSQLite():
|
||||
return sqlite3.Open(dbProperties)
|
||||
return sqlite3.Open(dbProperties, cache)
|
||||
case dbProperties.ConnectionString.IsPostgres():
|
||||
return postgres.Open(dbProperties)
|
||||
return postgres.Open(dbProperties, cache)
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected database type")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue