Documentation
Welcome to the Layercache documentation.
Layercache stacks memory, Redis, and disk behind a single API with stampede prevention, tag invalidation, stale-while-revalidate, and full observability.
How It Works
Every read follows the same path:
- Check L1 Memory first (fastest, in-process).
- If miss, check L2 Redis (shared across instances).
- If miss, check L3 Disk (persistent fallback).
- If all miss, run the origin fetcher once (single-flight).
- Backfill upper layers so next reads return faster.
Layercache keeps responses stable under pressure with stale serving, circuit breakers, and timeout guards.
Version 3.0 Highlights
Layercache 3.0 tightens production defaults and updates the docs/runtime surface for distributed deployments:
RedisTagIndexnow uses 16 known-key shards by default, with amigrate-tag-indexCLI command for older single-set indexes.- Production CLI commands reject plaintext
redis://URLs unless--allow-plaintextis passed. - Express and Hono implicit URL cache keys strip sensitive query parameters, and non-2xx JSON responses are skipped by default.
RedisInvalidationBussupports signed invalidation messages, andRedisGenerationStorepersists generation rotations across instances.- The documentation site now runs on Rspress and deploys through GitHub Pages.
Read the migration guide before upgrading an existing Redis-backed deployment.
Quick Links
- Getting Started — Install and configure your first cache stack
- Tutorial — 10-step walkthrough of production features
- API Reference — Complete method and option documentation
- Integrations — Express, Fastify, NestJS, Hono, tRPC, GraphQL