[feature/performance] sqlite pragma optimize on close (#2596)

* wrap database drivers in order to handle error processing, hooks, etc

* remove dead code

* add code comment, remove unused blank imports
This commit is contained in:
kim 2024-02-07 14:43:27 +00:00 committed by GitHub
commit 6738fd5bb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 372 additions and 660 deletions

View file

@ -35,7 +35,7 @@ import (
)
type listDB struct {
db *DB
db *bun.DB
state *state.State
}
@ -198,7 +198,7 @@ func (l *listDB) DeleteListByID(ctx context.Context, id string) error {
}
}()
return l.db.RunInTx(ctx, func(tx Tx) error {
return l.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
// Delete all entries attached to list.
if _, err := tx.NewDelete().
Table("list_entries").
@ -515,7 +515,7 @@ func (l *listDB) PutListEntries(ctx context.Context, entries []*gtsmodel.ListEnt
}()
// Finally, insert each list entry into the database.
return l.db.RunInTx(ctx, func(tx Tx) error {
return l.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
for _, entry := range entries {
entry := entry // rescope
if err := l.state.Caches.GTS.ListEntry.Store(entry, func() error {