Skip to content

Commit

Permalink
thank you aaron francis
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheraff committed Jun 29, 2024
1 parent c863cb6 commit 08dda52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/v3/lib/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class Queue<
if (done.has(str)) return
done.add(str)
setImmediate(() => job.dispatch({ date: date.toISOString() }))
setTimeout(() => done.delete(str), 10).unref()
setTimeout(() => done.delete(str), 1000).unref()
}))
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/v3/lib/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export class SQLiteStorage implements Storage {
if (!db || typeof db === 'string') {
this.#db = new BetterSqlite3(db)
this.#db.pragma('journal_mode = WAL')
this.#db.pragma('busy_timeout = 100')
this.#db.pragma('synchronous = NORMAL')
this.#db.pragma('cache_size = 2000')
this.#db.pragma('temp_store = MEMORY')
this.#externalDb = false
} else {
this.#db = db
Expand Down Expand Up @@ -230,7 +234,6 @@ export class SQLiteStorage implements Storage {
CREATE INDEX IF NOT EXISTS ${stepsTable}_task_id ON ${stepsTable} (task_id);
CREATE TABLE IF NOT EXISTS ${eventsTable} (
id INTEGER PRIMARY KEY AUTOINCREMENT,
queue TEXT NOT NULL,
key TEXT NOT NULL,
created_at REAL NOT NULL DEFAULT (unixepoch('subsec')),
Expand Down Expand Up @@ -854,7 +857,9 @@ export class SQLiteStorage implements Storage {
}

close() {
if (!this.#externalDb)
if (!this.#externalDb) {
this.#db.pragma('optimize')
this.#db.close()
}
}
}

0 comments on commit 08dda52

Please sign in to comment.