npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@monlite/kv

v0.6.0

Published

Redis-like key-value cache for monlite: get/set/incr with TTL, sorted sets, pub/sub — on SQLite (@monlite/core) or Postgres (@monlite/postgres).

Readme

@monlite/kv

A Redis-like key-value cache for monlite — get/set/incr with TTLs, atomic locks, sorted sets, and pub/sub. Part of the local AI-agent harness (cache + queue + cron, replacing Redis).

  • SQLite (@monlite/core) — kv(db), a synchronous API.
  • Postgres (@monlite/postgres) — pgKv(db), the same surface with an async API (await cache.get(...)).
npm install @monlite/core @monlite/kv

Quick start

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.

API

| 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). |

Options

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.

License

MIT