Skip to content

Engine Options & Durability Modes โ€‹

FLASH v1.2.5+ exposes engineOptions on FlashClient and FlashDatabase for throughput tuning without sacrificing balanced crash safety.


Quick Reference โ€‹

javascript
import { FlashClient } from "flash-zk";

const client = new FlashClient({
  storagePath: "./flash_data",
  engineOptions: {
    durability: "balanced", // strict | balanced | throughput
    memtableThreshold: 4 * 1024 * 1024, // 4 MB default
    useWorkerFlush: true, // background SSTable writes
    deferMerkleOnWrite: true, // defer Merkle rebuild on bulk paths
  },
});

Durability Modes โ€‹

ModeWAL / Oplog behaviorUse when
strictfsync after every frameFinancial logs, audit trails, max safety
balanced (default)Batch fsync every 64 ops or 25 ms; full sync on close()Production apps, encrypted CRUD
throughputNo automatic fsync until close()Benchmarks, bulk import, disposable data
javascript
// Maximum durability
engineOptions: {
  durability: "strict";
}

// Bulk import (call client.close() to flush)
engineOptions: {
  durability: "throughput";
}

TIP

Always call await client.close() (or collection.close()) before exit โ€” all modes flush pending WAL data on close.

Writes append FAR2 frames with CRC-32 for corruption detection (payloads remain AES-GCM sealed). Older FARC files still recover. Passphrase stretching is still PBKDF2 100k; the derived key is cached in-process so extra FlashCipher instances are not paid again.


Memtable Threshold โ€‹

Default: 4 MB (was 64 KB in early releases).

Larger memtables reduce flush frequency and improve write throughput:

javascript
engineOptions: {
  memtableThreshold: 8 * 1024 * 1024, // 8 MB
}

Worker Flush โ€‹

When enabled (default), large flushes (โ‰ฅ512 records) run in a worker thread:

javascript
engineOptions: {
  useWorkerFlush: true;
}

Write Patterns โ€‹

PatternExpected throughput*Notes
insertOne loop~300 ops/secMerkle + encryption per doc
insertMany batch~2,500โ€“4,000 ops/secSingle WAL batch + deferred Merkle
Blind index reads~5,000โ€“6,000 ops/secPoint lookups

*Apple Silicon / Node 20+, encrypted E2E. Run npm run benchmark on your hardware.


Honest config

Unknown, misplaced, or mistyped options throw on FlashClient, FlashDatabase, and FlashServer โ€” they are not silently ignored. listTrash / listDeletions also throw if that feature is disabled.

Trash archive (undo delete) โ€‹

Bounded .flash-trash file โ€” enabled by default on disk databases:

javascript
engineOptions: {
  trash: {
    enabled: true,
    maxEntries: 500,
    maxBytes: 2 * 1024 * 1024,
    maxAgeMs: 7 * 24 * 3600 * 1000,
  },
},

See Trash & Restore for restoreOne, listTrash, and eviction rules.


Deletion activity log โ€‹

Optional permanent metadata-only log โ€” disabled by default (opt-in). On disk the file is a single deflate-compressed, AES-sealed blob (key derived from secretKey).

javascript
engineOptions: {
  deletionLog: {
    enabled: true,
  },
},

See Trash & Restore โ€” Deletion activity log for listDeletions and purge behavior.


Low-Level API โ€‹

Direct FlashArc / FlashOplog usage:

javascript
import { FlashArc } from "flash-zk/engine/arc.mjs";

// Legacy: syncOnWrite true โ†’ strict mode
const strict = new FlashArc("./data/commit.farc", { syncOnWrite: true });

// Explicit durability
const balanced = new FlashArc("./data/commit.farc", { durability: "balanced" });

Zero-knowledge encrypted intelligence ยท Apache 2.0