Session stores

b.session writes through a pluggable storage backend. The default uses b.clusterStorage, which dispatches to the framework's main DB in single-node deployments and to the configured external DB in cluster mode. Sealed-column sealing, derived-hash lookup, and audit emission live in b.session itself, not in the store — adapters only need to expose the two primitives b.session calls into:

execute(sql, params) -> Promise<{ rows: Row[], rowCount: number }> executeOne(sql, params) -> Promise

b.session.stores.localDbThin({ file }) ships first-party. It wraps b.localDb.thin with the matching _blamejs_sessions schema (sidHash PRIMARY KEY, userId, userIdHash, data, createdAt, expiresAt, lastActivity) plus the indexes session-side queries need (userIdHash for destroyAllForUser, expiresAt for purgeExpired). Operators typically point file at tmpfs (e.g. /dev/shm/blamejs-sessions.db) so session inserts run RAM-fast and don't compete with the main DB's encryption-flush cycle.

Wire it once at boot, before the first session call:

var sessionStore = b.session.stores.localDbThin({ file: "/dev/shm/sessions.db" }); b.session.useStore(sessionStore);

b.session.stores.localDbThin(opts) #

stable0.8.61
{
  {
    file:       string,                    // required absolute path
    recovery?:  "refuse" | "rename-and-recreate", // forwards to b.localDb.thin
    pragmas?:   object,                    // extra PRAGMA overrides
    audit?:     boolean,                   // localDb.thin audit emission
  }
}

Returns a session-store adapter backed by a dedicated b.localDb.thin SQLite file. The adapter exposes execute(sql, params) and executeOne(sql, params) — the contract b.session consumes — so passing it to b.session.useStore(store) redirects every session read/write to the isolated file without touching the framework's main DB.

Typical use is to point file at tmpfs (/dev/shm/sessions.db on Linux, an in-memory volume on Windows) so session inserts don't fight the main DB's WAL fsync + encrypted-at-rest re-flush cycle. The adapter creates the schema on first open, so no manual migration is required.

var b = require("@blamejs/core");
var store = b.session.stores.localDbThin({ file: "/dev/shm/sessions.db" });
b.session.useStore(store);
// From here on every b.session.* call routes through the tmpfs file.

Last updated 2026-08-08T16:39:49.652Z by seeder.