@coderbuzz/kvs
v0.6.0
Published
Bun-only embeddable key-value store on SQLite (sync or async) or PostgreSQL: atomic commits with versionstamps, TTL, watch, and a durable queue with leases and dead letters.
Maintainers
Readme
KVS — @coderbuzz/kvs
Multi-backend key-value store for Bun (1.2.21+). Embed directly in your app — zero HTTP deps. Supports SQLite (sync or async) and PostgreSQL (async).
Atomic transactions (with sum counters), batch reads, TTL expiry, persistent queue with retries, real-time watch, and push-based listeners.
Installation
npm install @coderbuzz/kvsQuick Start
import { KVStore, AsyncKVStore } from "@coderbuzz/kvs";
// Sync — SQLite (bun:sqlite)
const store = new KVStore("kv.db");
store.set(["greeting"], "hello world");
console.log(store.get(["greeting"])?.value);
// Atomic counters
const views = store.increment(["page", "views"]);
store.increment(["page", "views"], 5); // custom delta
// Queue: leases, retries with backoff, dead letters
store.enqueue({ task: "send-email" }, { topic: "mailer", maxAttempts: 3 });
store.addQueueListener("mailer", async (msg) => {
await processTask(msg.payload); // resolves → acked, throws → retried
});
// Async — SQLite or PostgreSQL (bun:sql)
const asyncStore = new AsyncKVStore("sqlite://kv.db");
await asyncStore.set(["greeting"], "hello world");
console.log(await asyncStore.get(["greeting"]));
// PostgreSQL
const pgStore = new AsyncKVStore("postgres://user:pass@localhost:5432/kvdb");
await pgStore.set(["key"], "value");Documentation
Full API reference: DOCS.md
License
MIT © 2026 Indra Gunawan
