Enable Sqlite WAL mode by default

WAL provides more concurrency as readers do not block writers and,
a writer does not block readers. Reading and writing can proceed concurrently.

This change might reduce the number of errors related to locked databases.

For reference: https://sqlite.org/wal.html
This commit is contained in:
Frédéric Guillot
2023-02-10 19:30:37 -08:00
committed by Frédéric Guillot
parent 1e304f4ad6
commit 5e4d506b28
3 changed files with 10 additions and 2 deletions

View File

@@ -36,6 +36,12 @@ class Sqlite extends Base
}
$this->pdo = new PDO('sqlite:'.$settings['filename'], null, null, $options);
// Official docs: https://sqlite.org/wal.html
if (isset($settings['wal_mode']) && $settings['wal_mode'] === true) {
$this->pdo->exec('PRAGMA journal_mode=wal');
}
$this->enableForeignKeys();
}