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

@ken0106/cache-do

v0.1.0-alpha.0

Published

Durable Object SQLite cache backend for paleta. Free-tier compatible.

Readme

@ken0106/cache-do

Durable Object SQLite cache backend for @ken0106/core. Cross-colo palette cache, free-tier compatible, ~2.7 KB of wrapper code on top of the DO runtime.

npm install @ken0106/core @ken0106/cache-do

Why

caches.default is colo-local — a request that decodes an image in Ashburn doesn't benefit users hitting the same URL from Frankfurt. A Durable Object with SQLite storage gives you one globally-consistent cache for ~free (SQLite DOs are on the Workers Free plan).

Paleta JSON is tiny (~300 bytes per entry), so a single 10 GB DO fits ~35M distinct palettes before you need to shard.

Setup

wrangler.jsonc:

{
  "durable_objects": {
    "bindings": [
      { "name": "PALETA_CACHE", "class_name": "PaletaCacheDO" }
    ]
  },
  "migrations": [
    { "tag": "v1", "new_sqlite_classes": ["PaletaCacheDO"] }
  ]
}

Worker entrypoint — re-export the class so wrangler can instantiate it:

import { paletaDurableCache } from "@ken0106/cache-do";
export { PaletaCacheDO } from "@ken0106/cache-do";

export default {
  async fetch(req, env) {
    const result = await getPalette(url, {
      cache: caches.default,                          // colo-local tier
      crossColoCache: paletaDurableCache(env.PALETA_CACHE),  // cross-colo tier
      // …
    });
    return Response.json(result);
  },
};

How the tiers interact

  1. caches.default hit → instant (~1 ms).
  2. Miss → DO cross-colo lookup (~15–30 ms, globally consistent).
  3. DO hit → value promoted into caches.default so neighboring requests in the same colo hit tier 1 next time.
  4. Miss → run the pipeline, write both tiers.
  5. DO writes are fire-and-forget — a slow DO never blocks the response.

Sharding

For workloads that exceed a single DO's 10 GB limit:

paletaDurableCache(env.PALETA_CACHE, (key) => `shard-${key[0]}`);

The hash-shard function is called per key and must be deterministic.

Expiry

PaletaCacheDO self-manages expired entries via a storage.setAlarm that fires at the next-earliest TTL and sweeps the SQLite table.

License

MIT