LazyLayersv0.6.3

Introduction

Add read-through caching to Node.js or Cloudflare Workers, with Redis or Cloudflare KV as L2.

LazyLayers is a cache for Node.js services and Cloudflare Workers. Your application reads with getOrSet, supplies a loader for misses, and invalidates cached values after database writes.

Start with L1 in one process. Add Redis or Cloudflare KV as shared L2. Node.js can use an event bus to fan out invalidations. Cloudflare Workers can publish application invalidations to a Queue for retryable KV deletion. setupCache configures the Node.js layers, waits for readiness, and provides managed cleanup.

These docs describe the 0.6.3 release. Review the Redis store reference when upgrading an existing Redis namespace.

Start here

The three parts

PartWhat it does
L1Keeps encoded values in this process, with LRU eviction and memory bounds
L2Shares cached values through Redis or Cloudflare KV
Event busOn Node.js, sends invalidations and eligible loader results to peer instances

In-flight dedupe shares same-key loader work within a process. Redis leases coordinate loads across instances. A successful loader can prime peer L1 caches when delivery, payload size, and memory admission allow it.

The database remains the source of truth. Cache events can be delayed or missed, and a cache lease does not guarantee exactly-once execution. Use caching for reads that tolerate the configured freshness and failure behavior.

Choose the page for your task

TaskRead
Check runtime, modules, or TypeScript requirementsInstallation
Deploy a service with RedisProduction setup
Use Cloudflare KV from Workers or Node.jsCloudflare KV system design
Set memory and freshness limitsConfiguration
Handle slow loaders or dependency failuresFailure handling
Inspect entries, events, and metricsObservability
Coordinate a durable payment or order attemptTransaction coordination

Transaction coordination is an opt-in API under lazy-layers-cache/transactions. It uses an authoritative Redis primary and application-owned durable state, separately from L1/L2 caching.

Where to next

On this page