r/softwarearchitecture 5d ago

Tool/Product Crossflight: distributed cache stampede protection without replacing your cache

https://github.com/gkoos/crossflight

Crossflight is a small Node library for preventing cache stampedes across processes.

If multiple app instances miss the same cache key at the same time, they can all trigger the same expensive load at once. Crossflight adds a separate distributed coordination layer so only one process owns the in-flight load, writes the result, and lets the rest wait for the same value instead of re-running the loader.

The project is intentionally decoupled from the storage layer: it wraps the cache you already use, and keeps coordination separate. The built-in adapters currently cover:

  • cache-manager
  • Keyv
  • Cacheable

A cache-manager-backed cache can be paired with Memcached for values and Redis for coordination, or any other combination that satisfies the adapter/coordinator interfaces. The current built-in coordinator is Redis.

This is useful for services where you want to reduce duplicate DB/API work without forcing a big cache migration.

Demo: https://github.com/gkoos/crossflight-demo

3 Upvotes

Duplicates