@nxtedition/lib 26.0.10 → 26.0.11

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.
Files changed (2) hide show
  1. package/cache.js +31 -33
  2. package/package.json +1 -1
package/cache.js CHANGED
@@ -80,39 +80,37 @@ export class AsyncCache {
80
80
  this.#lru =
81
81
  opts?.lru === false || opts?.lru === null ? null : new LRUCache({ max: 4096, ...opts?.lru })
82
82
 
83
- for (let n = 0; true; n += 1) {
84
- try {
85
- this.#db = new DatabaseSync(location, { timeout: 20, ...opts?.db })
86
-
87
- this.#db.exec(`
88
- PRAGMA journal_mode = WAL;
89
- PRAGMA synchronous = NORMAL;
90
- PRAGMA temp_store = memory;
91
- PRAGMA optimize;
92
-
93
- CREATE TABLE IF NOT EXISTS cache (
94
- key TEXT PRIMARY KEY NOT NULL,
95
- val TEXT NOT NULL,
96
- ttl INTEGER NOT NULL,
97
- stale INTEGER NOT NULL
98
- );
99
- `)
100
-
101
- this.#getQuery = this.#db.prepare(`SELECT val, ttl, stale FROM cache WHERE key = ?`)
102
- this.#setQuery = this.#db.prepare(
103
- `INSERT OR REPLACE INTO cache (key, val, ttl, stale) VALUES (?, ?, ?, ?)`,
104
- )
105
- this.#delQuery = this.#db.prepare(`DELETE FROM cache WHERE key = ?`)
106
- } catch (err) {
107
- this.#db?.close()
108
- this.#db = null
109
-
110
- this.#getQuery = null
111
- this.#setQuery = null
112
- this.#delQuery = null
113
-
114
- process.emitWarning(err)
115
- }
83
+ try {
84
+ this.#db = new DatabaseSync(location, { timeout: 20, ...opts?.db })
85
+
86
+ this.#db.exec(`
87
+ PRAGMA journal_mode = WAL;
88
+ PRAGMA synchronous = NORMAL;
89
+ PRAGMA temp_store = memory;
90
+ PRAGMA optimize;
91
+
92
+ CREATE TABLE IF NOT EXISTS cache (
93
+ key TEXT PRIMARY KEY NOT NULL,
94
+ val TEXT NOT NULL,
95
+ ttl INTEGER NOT NULL,
96
+ stale INTEGER NOT NULL
97
+ );
98
+ `)
99
+
100
+ this.#getQuery = this.#db.prepare(`SELECT val, ttl, stale FROM cache WHERE key = ?`)
101
+ this.#setQuery = this.#db.prepare(
102
+ `INSERT OR REPLACE INTO cache (key, val, ttl, stale) VALUES (?, ?, ?, ?)`,
103
+ )
104
+ this.#delQuery = this.#db.prepare(`DELETE FROM cache WHERE key = ?`)
105
+ } catch (err) {
106
+ this.#db?.close()
107
+ this.#db = null
108
+
109
+ this.#getQuery = null
110
+ this.#setQuery = null
111
+ this.#delQuery = null
112
+
113
+ process.emitWarning(err)
116
114
  }
117
115
  }
118
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.0.10",
3
+ "version": "26.0.11",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",