
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@monlite/kv
Advanced tools
Redis-like local key-value cache for @monlite/core: get/set/incr with TTL, on SQLite.
A Redis-like key-value cache for @monlite/core,
backed by SQLite. Synchronous get/set/incr with TTLs — part of the local AI-agent harness
(cache + queue + cron, replacing Redis locally).
npm install @monlite/core @monlite/kv
import { createDb } from "@monlite/core";
import { kv } from "@monlite/kv";
const db = createDb("app.db");
const cache = kv(db);
cache.set("session:42", { user: "ali" }, { ttl: 60_000 }); // expires in 60s
cache.get("session:42"); // { user: "ali" } — synchronous, no await
cache.incr("hits"); // 1
cache.incr("hits", 5); // 6
cache.ttl("session:42"); // ~60000 (ms remaining)
The cache is synchronous (local SQLite — no network, no await), durable (survives
restarts), and stored in your app's database. Use :memory: if you want a purely ephemeral
cache.
| Method | Description |
|---|---|
get(key) | Value, or undefined (also if expired). |
set(key, value, { ttl? }) | Store any JSON-serializable value; ttl in ms (optional). |
setNX(key, value, { ttl? }) | Atomic set-if-absent (Redis SET NX); returns true if acquired. The lock/nonce primitive. |
has(key) / delete(key) | Existence check / removal. |
incr(key, by?) / decr(key, by?) | Atomic numeric increment/decrement; returns the new value. |
mget(keys) | Array of values (undefined per missing/expired key). |
keys(prefix?) | Live keys in the namespace, optionally filtered by prefix. |
expire(key, ttl) | Set or refresh the TTL (ms); returns false if the key is absent. |
ttl(key) | Remaining ms; -1 = no expiry, -2 = key absent (Redis convention). |
size() / flush() | Count / clear all keys in the namespace. |
stop() | Clear the sweep timer (if sweepIntervalMs was set). |
kv(db, {
namespace: "sessions", // isolate multiple caches in one db (default: "default")
sweepIntervalMs: 60_000, // periodically purge expired keys (default: lazy-only)
});
Expired keys are removed lazily on read. Set sweepIntervalMs to also purge them on a timer.
Call cache.stop() to clear the timer when shutting down.
MIT
FAQs
Redis-like key-value cache for monlite: get/set/incr with TTL, sorted sets, pub/sub — on SQLite (@monlite/core) or Postgres (@monlite/postgres).
The npm package @monlite/kv receives a total of 26 weekly downloads. As such, @monlite/kv popularity was classified as not popular.
We found that @monlite/kv 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.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.