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

@ziggurat-cache/core

v0.1.2

Published

Multi-layer cache orchestrator with stampede protection

Downloads

477

Readme

@ziggurat-cache/core

Multi-layer cache orchestrator for TypeScript with built-in stampede protection and automatic backfill.

Part of the Ziggurat cache ecosystem.

Installation

npm install @ziggurat-cache/core

Features

  • Multi-layer caching - Stack multiple cache layers (memory, Redis, SQLite, etc.). Reads cascade through layers; misses automatically backfill higher layers.
  • Stampede protection - Concurrent wrap() calls for the same key coalesce into a single factory invocation.
  • Batch operations - mget, mset, mdel for efficient multi-key operations across all layers.
  • Event system - Built-in typed events for hit, miss, set, delete, error, backfill, and wrap operations.
  • Fully typed - Generic CacheEntry<T> ensures type safety from cache to consumer.
  • Resilient - Individual layer failures are silently skipped; a broken layer won't crash your app.

Quick Start

import { CacheManager, MemoryAdapter } from "@ziggurat-cache/core";

const cache = new CacheManager({
  namespace: "users",
  layers: [new MemoryAdapter({ defaultTtlMs: 300_000 })],
});

// wrap: fetch from cache or compute and cache
const user = await cache.wrap(`profile:${userId}`, async () =>
  db.users.findById(userId),
);

Multi-Layer Example

import { CacheManager, MemoryAdapter } from "@ziggurat-cache/core";
import { RedisAdapter } from "@ziggurat-cache/redis";
import Redis from "ioredis";

const cache = new CacheManager({
  namespace: "products",
  layers: [
    new MemoryAdapter({ defaultTtlMs: 30_000 }), // L1: 30s
    new RedisAdapter({ client: new Redis(), defaultTtlMs: 600_000 }), // L2: 10min
  ],
});

// L1 miss -> L2 hit -> value returned + L1 backfilled
const product = await cache.wrap(id, async () => api.getProduct(id));

Events

cache.on("hit", (e) => console.log(`HIT ${e.key} from ${e.layerName}`));
cache.on("miss", (e) => console.log(`MISS ${e.key}`));
cache.on("backfill", (e) =>
  console.log(`BACKFILL ${e.key} from ${e.fromLayerName}`),
);
cache.on("wrap:coalesce", (e) => console.log(`COALESCE ${e.key}`));

API

CacheManager

| Method | Description | | ------------------------------- | ----------------------------------------- | | get<T>(key) | Read from cache, cascading through layers | | set<T>(key, value, ttlMs?) | Write to all layers | | delete(key) | Delete from all layers | | wrap<T>(key, factory, ttlMs?) | Get-or-compute with stampede protection | | mget<T>(keys) | Batch get across layers | | mset<T>(entries, ttlMs?) | Batch set across layers | | mdel(keys) | Batch delete across layers | | on(event, listener) | Subscribe to cache events | | off(event, listener) | Unsubscribe from cache events |

MemoryAdapter

In-process cache using node-cache. Included in this package.

BaseCacheAdapter

Abstract base class for building custom adapters. Implement get, set, delete, and clear.

Documentation

See the full documentation for detailed guides on core concepts, custom adapters, and advanced usage.

License

MIT