mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 23:59:59 -05:00
perf(ext/cache): set journal_mode=wal (#16231)
This commit is contained in:
parent
a2488ae792
commit
4d6aed1b52
1 changed files with 11 additions and 1 deletions
12
ext/cache/sqlite.rs
vendored
12
ext/cache/sqlite.rs
vendored
|
@ -45,6 +45,16 @@ impl SqliteBackedCache {
|
|||
let connection = rusqlite::Connection::open(&path).unwrap_or_else(|_| {
|
||||
panic!("failed to open cache db at {}", path.display())
|
||||
});
|
||||
// Enable write-ahead-logging mode.
|
||||
let initial_pragmas = "
|
||||
-- enable write-ahead-logging mode
|
||||
PRAGMA journal_mode=WAL;
|
||||
PRAGMA synchronous=NORMAL;
|
||||
PRAGMA optimize;
|
||||
";
|
||||
connection
|
||||
.execute_batch(initial_pragmas)
|
||||
.expect("failed to execute pragmas");
|
||||
connection
|
||||
.execute(
|
||||
"CREATE TABLE IF NOT EXISTS cache_storage (
|
||||
|
@ -117,7 +127,7 @@ impl Cache for SqliteBackedCache {
|
|||
tokio::task::spawn_blocking(move || {
|
||||
let db = db.lock();
|
||||
let cache_exists = db.query_row(
|
||||
"SELECT count(cache_name) FROM cache_storage WHERE cache_name = ?1",
|
||||
"SELECT count(id) FROM cache_storage WHERE cache_name = ?1",
|
||||
params![cache_name],
|
||||
|row| {
|
||||
let count: i64 = row.get(0)?;
|
||||
|
|
Loading…
Reference in a new issue