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

@gnldev/cache

v0.5.0

Published

Cross-run content-hash cache on @gnldev/durable. Within-run reuse = journal replay; across-run reuse = cache.

Readme

@gnldev/cache

Cross-run content-hash cache on top of a storage's cache port (CacheStore), not the run journal. The key is run-independent (<namespace>:<argsHash(key)>) → a result computed in one run is reused in other runs. (Within-run reuse is already journal replay; this closes the across-run gap.)

Best-effort by design. A cache is an accelerator, so a store error never fails the run: a failed get counts as a miss, a failed set is a no-op, and getOrCompute computes anyway. Pass onError if you want to see those. (runs/memory stay strict — this leniency is the cache's alone.)

Install: pnpm add @gnldev/cache — or use it from a repo clone: pnpm install && pnpm -r build.

npm i @gnldev/cache   # peer: @gnldev/durable
import { createCache } from '@gnldev/cache';
import { SqliteStorage } from '@gnldev/durable/sqlite';

const storage = new SqliteStorage('runs.db');
const cache = createCache(storage.cache, 'embeddings');   // the CACHE port, not storage.runs

// Same input → embed computed once; later runs read it back from the cache store.
const vec = await cache.getOrCompute({ text: 'hello' }, () => embed('hello'));

API

  • createCache(store: CacheStore, namespace = 'default', opts?: { onError?(op, err) }) → Cache — the first argument is a CacheStore (storage.cache), not a journal.
  • cache.get(key) · cache.set(key, value, opts?) · cache.getOrCompute(key, compute, opts?) — the trailing opts is { ttlMs? }, honoured by stores whose capability is 'ttl' (SQLite/Postgres/Redis; InMemory is 'full').
  • cache.stats() → { hits, misses, hitRate, size }in-process counters, not persistent: they reset when the process does, and size is only the keys this instance has touched, because CacheStore offers no enumeration.
  • cache.invalidate(key?) → number — with a key, deletes that one; without, deletes every key this instance knows about. For the same reason as size, that is not "clear the whole store".

Studio's Cache view is a wrapper over these last two (packages/studio/src/server.ts, StudioCache).

key can be any value (hashed stably with argsHash). Values are wrapped as { v } before storing, which is how a cached undefined stays distinguishable from a miss.

How it works

The content-hash key is independent of the run id, so the cache outlives a single run's lifetime. It's ideal for expensive, pure computations (embed, retrieval, price calculation).

License

Apache-2.0 — see LICENSE.