diff options
Diffstat (limited to 'internal/storage')
| -rw-r--r-- | internal/storage/storage.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/storage/storage.go b/internal/storage/storage.go index d00d7bf..9ef9956 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go | |||
| @@ -22,6 +22,12 @@ func New(dbPath string) (*Storage, error) { | |||
| 22 | return nil, fmt.Errorf("failed to open database: %w", err) | 22 | return nil, fmt.Errorf("failed to open database: %w", err) |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | // Configure connection pool for SQLite | ||
| 26 | // SQLite works best with a single connection due to single-writer lock | ||
| 27 | db.SetMaxOpenConns(1) // Single connection (SQLite is single-writer) | ||
| 28 | db.SetMaxIdleConns(1) // Keep connection alive | ||
| 29 | db.SetConnMaxLifetime(0) // Never close the connection | ||
| 30 | |||
| 25 | // Configure SQLite for optimal performance | 31 | // Configure SQLite for optimal performance |
| 26 | pragmas := []string{ | 32 | pragmas := []string{ |
| 27 | "PRAGMA journal_mode=WAL", // Write-Ahead Logging for concurrency | 33 | "PRAGMA journal_mode=WAL", // Write-Ahead Logging for concurrency |
