Skip to main content

stalefree

tag-based cache invalidation through the database you already have — no Redis

DB

No Redis required

Coherence travels through the database your instances already share: Postgres LISTEN/NOTIFY across machines, a unix-socket mesh on one machine, in-process for a single node. No extra infrastructure to run.

Tx

Transactional invalidation

On Postgres, publishInTx runs pg_notify inside your business transaction — delivered on commit, dropped on rollback. “Wrote the row, crashed before invalidating, stale forever” cannot happen.

TTL

TTL is the backstop

Every entry has a TTL — no exceptions. The bus is best-effort by contract, so a lost invalidation message means stale until TTL, never stale forever. The API rejects infinite TTLs by design.

Tag

Tags + single-flight wrap

wrap(key, loader, {tags}) is read-through with in-process single-flight: concurrent misses share one loader run. invalidateTags evicts every entry carrying a tag — here and on every other instance.

L2

Optional shared L2

A Drizzle-backed table (SQLite, Postgres, MySQL) so a fresh instance starts warm and instances share loader work. On Postgres, make it UNLOGGED — cache rows are transient, and skipping WAL roughly doubles write throughput.

Zero

Framework-agnostic, fail-open

@stalefree/core has zero runtime dependencies; the @nest-native/cache adapter is a thin DI shell over it. Store/bus failures fail open — a degraded cache is a slower app, never a broken one.