
Security News
RubyGems Adds Cooldown Feature to Bundler for Newly Published Gems
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.
@snomiao/keyv-sqlite
Advanced tools
Multi-driver SQLite storage adapter for Keyv with support for node:sqlite, bun:sqlite, and better-sqlite3.
A high-performance SQLite cache store for keyv with support for multiple SQLite drivers.
Note: This is a fork of @resolid/keyv-sqlite by @huijiewei with multi-driver support for
node:sqlite,bun:sqlite, andbetter-sqlite3. See comparison below.
npm i @snomiao/keyv-sqlite
import KeyvSqlite from "@snomiao/keyv-sqlite"; // or: import { KeyvSqlite } from '...'
import Keyv from "keyv";
// Simple file path (recommended), note: WAL mode is enabled by default
const store = new KeyvSqlite("./cache.db");
const keyv = new Keyv({ store });
// In-memory cache
const store = new KeyvSqlite(":memory:");
const keyv = new Keyv({ store });
// Default (in-memory)
const store = new KeyvSqlite();
const keyv = new Keyv({ store });
import { createKeyv } from "@snomiao/keyv-sqlite";
// Simple file path
const keyv = createKeyv("./cache.db");
// With options
const keyv = createKeyv({ uri: "cache.sqlite" });
const store = new KeyvSqlite({
uri: "./cache.db",
table: "my_cache", // Custom table name
wal: true, // WAL mode (default: true)
busyTimeout: 10000, // Busy timeout in ms
iterationLimit: 100, // Iterator batch size
});
await needed for instantiationnode:sqlite, bun:sqlite, and better-sqlite3new KeyvSqlite(options?: KeyvSqliteOptions | string)
Pass a string for the file path, or an options object for advanced configuration.
All methods are async to match the Keyv interface:
get(key) - Get a valuegetMany(keys) - Get multiple valuesset(key, value, ttl?) - Set a value with optional TTLdelete(key) - Delete a valuedeleteMany(keys) - Delete multiple valuesclear() - Clear all valuesiterator(namespace?) - Async iterator over entriesdisconnect() - Close the database connection// Use node:sqlite explicitly
const store = new KeyvSqlite({
uri: "cache.sqlite",
driver: "node:sqlite",
});
// Use bun:sqlite explicitly
const store = new KeyvSqlite({
uri: "cache.sqlite",
driver: "bun:sqlite",
});
// Use better-sqlite3 explicitly
const store = new KeyvSqlite({
uri: "cache.sqlite",
driver: "better-sqlite3",
});
import Database from "better-sqlite3";
const store = new KeyvSqlite({
uri: "cache.sqlite",
driver: Database, // Pass the driver constructor directly
});
The library auto-detects and uses the best available driver for your runtime:
--experimental-sqlite flag)npm install better-sqlite3Native drivers are pre-loaded at module initialization using top-level await, making the constructor fully synchronous.
node:sqlite support)bun:sqlite supportbetter-sqlite3 package installedtype KeyvSqliteOptions = {
uri?: string; // Database file path (default: ":memory:")
driver?: DriverType | DriverModule; // Driver selection (default: "auto")
table?: string; // Table name (default: "caches")
wal?: boolean; // Enable WAL mode (default: true)
busyTimeout?: number; // Busy timeout in ms (default: 5000)
iterationLimit?: number; // Iterator batch size (default: 10)
};
This fork (@snomiao/keyv-sqlite) differs from the original @resolid/keyv-sqlite in the following ways:
| Feature | Original (@resolid) | This Fork (@snomiao) |
|---|---|---|
| SQLite drivers | ✅ better-sqlite3 only | ✅ Multi-driver (node:sqlite, bun:sqlite, better-sqlite3) |
| Native drivers | ❌ No | ✅ node:sqlite (Node 22.5+), bun:sqlite |
| Cross-runtime | ⚠️ Node.js only | ✅ Node.js, Bun, Deno |
| WAL mode | ⚠️ Opt-in (off by default) | ✅ Enabled by default |
| String parameter | ❌ No | ✅ Yes (new KeyvSqlite('./db')) |
| Benchmark workflow | ❌ No | ✅ Comprehensive multi-driver benchmarks |
The main difference is multi-driver support with automatic runtime detection:
Upstream approach:
import Database from "better-sqlite3"; // ← Hardcoded, must have better-sqlite3
This fork approach:
// Pre-loads native drivers at module initialization (top-level await)
let nodeSqliteDriver = await import("node:sqlite"); // ← Zero dependencies!
let bunSqliteDriver = await import("bun:sqlite"); // ← Zero dependencies!
let betterSqlite3 = await import("better-sqlite3"); // ← Fallback
// Auto-selects best available driver
// OR accepts custom driver: new KeyvSqlite({ driver: MyCustomDriver })
This allows the fork to:
If migrating from @resolid/keyv-sqlite:
- npm install @resolid/keyv-sqlite
+ npm install @snomiao/keyv-sqlite
The API is backwards compatible. Simply change the package name - your existing code will continue to work!
Optional improvements:
enableWALMode → wal (both work)new KeyvSqlite('./db')driver option)This fork is based on the excellent work by @huijiewei in keyv-sqlite. The multi-driver support and cross-runtime compatibility were built on top of their solid foundation.
MIT.
Thanks to JetBrains for the OSS development license.
FAQs
Multi-driver SQLite storage adapter for Keyv with support for node:sqlite, bun:sqlite, and better-sqlite3.
We found that @snomiao/keyv-sqlite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.