Production-Ready
Multi-Layer Caching
for Node.js

Stack multiple caching layers with automatic fallback, TTL management, and a simple API. Build resilient caching strategies in minutes.

example.ts

Everything You Need for Production Caching

Multi-Layer Stacking

Stack memory, Redis, disk, and Memcached behind a single API. Automatic backfill across layers.

Stampede Prevention

Per-key mutex prevents thundering herd on cache misses. Distributed single-flight via Redis leases.

Tag Invalidation

Invalidate by tag, pattern, or prefix. Trie-backed index for efficient lookups. Distributed invalidation via Redis pub/sub.

Stale-While-Revalidate

Serve stale data while refreshing in the background. Configurable freshness windows per layer.

Circuit Breaker

Auto-open after consecutive failures. Graceful degradation when layers are unhealthy.

Distributed Single-Flight

Cross-process request deduplication via Redis. Lease-based locking with automatic renewal.

How It Works

Data flows through layers from fastest to slowest, with automatic backfill

🔲Memory (L1)
< 1ms
🗄️Redis (L2)
~ 5ms
💾Disk (L3)
~ 20ms
🌐Data Source
varies

How Layercache Compares

FeatureLayercachenode-cache-managerkeyvcacheable
Multi-layer stacking
Stampede prevention
Tag invalidation
Pattern invalidation
Stale-while-revalidate
Circuit breaker
Write-behind
Adaptive TTL
Generation versioning
Negative caching
Per-layer TTL
Distributed single-flight
Cross-server invalidation
Snapshot persistence
Memcached support
Disk layer
Prometheus metrics
OpenTelemetry
Admin CLI

Ready to Cache Smarter?

Get started with Layercache in minutes. Production-ready caching with zero configuration headaches.