@stoolap/node 0.3.7 → 0.4.1
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.
- package/README.md +19 -22
- package/lib/transaction.js +6 -1
- package/package.json +6 -6
- package/src/stoolap.c +1 -0
package/README.md
CHANGED
|
@@ -127,7 +127,7 @@ import { Database, RunResult } from '@stoolap/node';
|
|
|
127
127
|
|
|
128
128
|
#### Persistence
|
|
129
129
|
|
|
130
|
-
File-based databases persist data to disk using WAL (Write-Ahead Logging) and
|
|
130
|
+
File-based databases persist data to disk using WAL (Write-Ahead Logging) and an immutable volume-based storage engine. Hot data lives in memory, cold data is sealed into columnar `.vol` files with zone maps, bloom filters, and LZ4 compression. Data survives process restarts.
|
|
131
131
|
|
|
132
132
|
```js
|
|
133
133
|
const db = await Database.open('./mydata');
|
|
@@ -148,18 +148,18 @@ await db2.close();
|
|
|
148
148
|
Pass configuration as query parameters in the path:
|
|
149
149
|
|
|
150
150
|
```js
|
|
151
|
-
// Maximum durability: fsync on every
|
|
152
|
-
const db = await Database.open('./mydata?
|
|
151
|
+
// Maximum durability: fsync on every write
|
|
152
|
+
const db = await Database.open('./mydata?sync_mode=full');
|
|
153
153
|
|
|
154
|
-
// High throughput: no fsync,
|
|
155
|
-
const db = await Database.open('./mydata?
|
|
154
|
+
// High throughput: no fsync, data durable at checkpoint
|
|
155
|
+
const db = await Database.open('./mydata?sync_mode=none');
|
|
156
156
|
|
|
157
|
-
// Custom
|
|
158
|
-
const db = await Database.open('./mydata?
|
|
157
|
+
// Custom checkpoint interval with compression
|
|
158
|
+
const db = await Database.open('./mydata?checkpoint_interval=60&compression=on');
|
|
159
159
|
|
|
160
160
|
// Multiple options
|
|
161
161
|
const db = await Database.open(
|
|
162
|
-
'./mydata?
|
|
162
|
+
'./mydata?sync_mode=normal&checkpoint_interval=120&compact_threshold=4'
|
|
163
163
|
);
|
|
164
164
|
```
|
|
165
165
|
|
|
@@ -169,26 +169,23 @@ Controls the durability vs. performance trade-off:
|
|
|
169
169
|
|
|
170
170
|
| Mode | Value | Description |
|
|
171
171
|
|------|-------|-------------|
|
|
172
|
-
| `none` | `
|
|
173
|
-
| `normal` | `
|
|
174
|
-
| `full` | `
|
|
172
|
+
| `none` | `sync_mode=none` | No fsync. Data durable only after checkpoint |
|
|
173
|
+
| `normal` | `sync_mode=normal` | Fsync every 1 second (batched). DDL fsyncs immediately (default) |
|
|
174
|
+
| `full` | `sync_mode=full` | Fsync on every write. Maximum durability |
|
|
175
175
|
|
|
176
176
|
##### All Configuration Parameters
|
|
177
177
|
|
|
178
178
|
| Parameter | Default | Description |
|
|
179
179
|
|-----------|---------|-------------|
|
|
180
|
-
| `
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
183
|
-
| `
|
|
184
|
-
| `
|
|
185
|
-
| `wal_max_size` | `67108864` | Max WAL file size before rotation (64 MB) |
|
|
186
|
-
| `commit_batch_size` | `100` | Commits to batch before syncing (normal mode) |
|
|
187
|
-
| `sync_interval_ms` | `10` | Minimum ms between syncs (normal mode) |
|
|
180
|
+
| `sync_mode` | `normal` | Sync mode: `none`, `normal`, or `full` |
|
|
181
|
+
| `checkpoint_interval` | `60` | Seconds between checkpoint cycles (seal + compact + WAL truncate) |
|
|
182
|
+
| `compact_threshold` | `4` | Sub-target volumes per table before merging |
|
|
183
|
+
| `target_volume_rows` | `1048576` | Target rows per cold volume. Controls compaction split boundary |
|
|
184
|
+
| `checkpoint_on_close` | `on` | Seal all hot rows on clean shutdown for fast startup |
|
|
188
185
|
| `wal_compression` | `on` | LZ4 compression for WAL entries |
|
|
189
|
-
| `
|
|
190
|
-
| `compression` | |
|
|
191
|
-
| `
|
|
186
|
+
| `volume_compression` | `on` | LZ4 compression for cold volume files |
|
|
187
|
+
| `compression` | `on` | Shorthand: set both `wal_compression` and `volume_compression` |
|
|
188
|
+
| `keep_snapshots` | `5` | Number of backup snapshot files to retain |
|
|
192
189
|
|
|
193
190
|
#### Cloning
|
|
194
191
|
|
package/lib/transaction.js
CHANGED
|
@@ -179,7 +179,12 @@ class Transaction {
|
|
|
179
179
|
executeBatchSync(sql, paramsArray) {
|
|
180
180
|
this.#checkSyncReady();
|
|
181
181
|
if (paramsArray.length > 0 && Array.isArray(paramsArray[0])) {
|
|
182
|
-
return this.#stoolap.txExecBatch(
|
|
182
|
+
return this.#stoolap.txExecBatch(
|
|
183
|
+
this.#dbPtr,
|
|
184
|
+
this.#ptr,
|
|
185
|
+
sql,
|
|
186
|
+
paramsArray,
|
|
187
|
+
);
|
|
183
188
|
}
|
|
184
189
|
let totalChanges = 0;
|
|
185
190
|
for (const params of paramsArray) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoolap/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "High-performance Node.js driver for Stoolap embedded SQL database",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"bench": "node benchmark.mjs"
|
|
19
19
|
},
|
|
20
20
|
"optionalDependencies": {
|
|
21
|
-
"@stoolap/lib-darwin-arm64": "0.
|
|
22
|
-
"@stoolap/lib-darwin-x64": "0.
|
|
23
|
-
"@stoolap/lib-linux-arm64-gnu": "0.
|
|
24
|
-
"@stoolap/lib-linux-x64-gnu": "0.
|
|
25
|
-
"@stoolap/lib-win32-x64-msvc": "0.
|
|
21
|
+
"@stoolap/lib-darwin-arm64": "0.4.1",
|
|
22
|
+
"@stoolap/lib-darwin-x64": "0.4.1",
|
|
23
|
+
"@stoolap/lib-linux-arm64-gnu": "0.4.1",
|
|
24
|
+
"@stoolap/lib-linux-x64-gnu": "0.4.1",
|
|
25
|
+
"@stoolap/lib-win32-x64-msvc": "0.4.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"better-sqlite3": "^12.6.2",
|