p14
Some checks failed
CI / test-build (push) Failing after 1m11s

This commit is contained in:
2025-12-15 00:53:35 +07:00
parent df475bc85e
commit 96a6b5a4cf
4 changed files with 339 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"time"
_ "modernc.org/sqlite"
)
@@ -22,11 +23,17 @@ func New(dbPath string) (*DB, error) {
return nil, fmt.Errorf("create db directory: %w", err)
}
conn, err := sql.Open("sqlite", dbPath+"?_foreign_keys=1")
// Configure connection pool
conn, err := sql.Open("sqlite", dbPath+"?_foreign_keys=1&_journal_mode=WAL")
if err != nil {
return nil, fmt.Errorf("open database: %w", err)
}
// Set connection pool settings for better performance
conn.SetMaxOpenConns(25) // Maximum number of open connections
conn.SetMaxIdleConns(5) // Maximum number of idle connections
conn.SetConnMaxLifetime(5 * time.Minute) // Maximum connection lifetime
db := &DB{DB: conn}
// Test connection