1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

perf(ext/cache): set journal_mode=wal (#16231)

This commit is contained in:
Satya Rohith 2022-10-10 13:05:57 +05:30 committed by GitHub
parent a2488ae792
commit 4d6aed1b52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

12
ext/cache/sqlite.rs vendored
View file

@ -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)?;