@nxtedition/nxt-undici 7.3.6 → 7.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,10 +73,14 @@ export class SqliteCacheStore {
73
73
  constructor(opts) {
74
74
  this.#db = new DatabaseSync(opts?.location ?? ':memory:', { timeout: 40, ...opts?.db })
75
75
 
76
+ const maxSize = opts?.maxSize ?? 256 * 1024 * 1024
76
77
  this.#db.exec(`
77
78
  PRAGMA journal_mode = WAL;
78
- PRAGMA synchronous = NORMAL;
79
- PRAGMA temp_store = memory;
79
+ PRAGMA synchronous = OFF;
80
+ PRAGMA wal_autocheckpoint = 10000;
81
+ PRAGMA cache_size = -${Math.ceil(maxSize / 1024 / 8)};
82
+ PRAGMA mmap_size = ${maxSize};
83
+ PRAGMA max_page_count = ${Math.ceil(maxSize / 4096)};
80
84
  PRAGMA optimize;
81
85
 
82
86
  CREATE TABLE IF NOT EXISTS cacheInterceptorV${VERSION} (
@@ -101,12 +105,6 @@ export class SqliteCacheStore {
101
105
  CREATE INDEX IF NOT EXISTS idx_cacheInterceptorV${VERSION}_deleteExpiredValuesQuery ON cacheInterceptorV${VERSION}(deleteAt);
102
106
  `)
103
107
 
104
- const maxSize = opts?.maxSize ?? 256 * 1024 * 1024
105
- {
106
- const { page_size: pageSize } = this.#db.prepare('PRAGMA page_size').get()
107
- this.#db.exec(`PRAGMA max_page_count = ${Math.ceil(maxSize / pageSize)}`)
108
- }
109
-
110
108
  this.#getValuesQuery = this.#db.prepare(`
111
109
  SELECT
112
110
  id,
@@ -159,6 +157,8 @@ export class SqliteCacheStore {
159
157
 
160
158
  purgeStale() {
161
159
  this.#prune()
160
+ this.#db.exec('PRAGMA wal_checkpoint(TRUNCATE)')
161
+ this.#db.exec('PRAGMA optimize')
162
162
  }
163
163
 
164
164
  close() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "7.3.6",
3
+ "version": "7.3.7",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",