Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jzszdznzzl/WABotJS/llms.txt
Use this file to discover all available pages before exploring further.
Utils.SQLiteStore is a string-keyed, Uint8Array-valued persistent store built on top of Node.js’s built-in node:sqlite module (available since Node.js v22.5). It operates as a simple key-value table and, when a TTL is provided, adds an expire column and a periodic background cleaner that purges stale rows. An in-memory TTLCache with a 10-minute TTL sits in front of all SQLite reads, reducing latency for frequently accessed keys without sacrificing durability.
Import & construction
Constructor
Directory in which the SQLite database file will be created. The file is
placed at
{dir}/{name}.sqlite. The directory is created recursively if it
does not already exist. Relative paths are resolved against process.cwd().Name of the store, used as both the SQLite filename stem and the table name.
Must match
/^[a-z0-9_]+$/ — throws TypeError otherwise.Optional time-to-live in milliseconds. When provided, each row is stored with
an
expire timestamp and is excluded from reads once that timestamp passes.
A background cleaner runs at min(ttl, 30 minutes) intervals to delete
expired rows. Must be a positive number if supplied.Properties
dir
name
db
node:sqlite DatabaseSync instance. Useful for executing custom queries directly.
Methods
initialize()
CREATE TABLE IF NOT EXISTS DDL, creates a key index, and starts the background TTL cleaner if a TTL was configured. Safe to call multiple times — subsequent calls are no-ops if the database is already open.
drop()
.sqlite, .sqlite-wal, and .sqlite-shm files from disk. Idempotent — calling drop() on an uninitialized store is a no-op.
get(key)
Uint8Array blob for the given key, or undefined if the key does not exist or has expired. Results are cached in the L1 TTLCache for 10 minutes; subsequent reads for the same key are served from memory without hitting SQLite.
The key to look up.
set(key, value)
INSERT ... ON CONFLICT DO UPDATE upsert. Also updates the L1 cache. When a TTL is configured, the expire column is set to Date.now() + ttl.
The key to insert or update.
The raw binary value to store. Throws
TypeError if not a Uint8Array.del(key)
has(key)
true if the key exists and is not expired. Checks the L1 cache first; falls back to a get() call against SQLite.
keys()
SELECT key query against SQLite. Does not use the L1 cache.
values()
Uint8Array blobs for all non-expired rows. Does not use the L1 cache.
entries()
{ key, value } objects for all non-expired rows, fetched in a single SELECT key, value query.
Storage format
All values are stored as rawBLOB columns. SQLiteStore performs no serialization — callers are responsible for encoding their data into Uint8Array before calling set() and decoding it after get().
Performance
SQLiteStore is tuned for low-latency, crash-safe local storage:
| Setting | Value | Effect |
|---|---|---|
| Journal mode | WAL | Allows concurrent reads during writes |
| Synchronous mode | NORMAL | Durable on OS crash; fast for most workloads |
| L1 cache TTL | 10 minutes | Frequently read keys served entirely from memory |
| Cleaner interval | min(ttl, 30 min) | Limits cleaner frequency for very long TTLs |