Migration Notes
Upgrading from earlier versions. All changes are additive and existing call sites compile unchanged.
From pre-cascadeTTL / pre-safety / pre-scoped-clear versions
- No code changes are required. All three features are additive. Existing call sites compile and run unchanged.
clearAllCachenow usesSCAN+UNLINKwhenkeyPrefixis set. If a test fixture relied on it wiping the entire DB, either unset the prefix for that test or callFLUSHDBdirectly via the raw client. Application code is unaffected.- Set a prefix if you share Redis. For any production deployment sharing Redis with another app or environment, configure
redis.keyPrefixto isolate this cache's keyspace and makeclearAllCachesafe by construction. safety.productionModedefaults fromNODE_ENVat cache construction time. Library consumers should pass it explicitly to drop the env coupling.- Adopt
cascadeTTL: trueselectivelyon writes where the parent's TTL is meaningfully longer than its embedded reference data. The simplest alternative is to raise the schema TTL of the reference entity to match the longest-lived parent.
From pre-atomic implementation
- Existing cached values stay readable. Compression is opt-in and the new connection pool defaults to 1 (single client).
clearAllCache()now requires explicit confirmation. Update any test fixtures that called it without arguments.invalidateEntity()now returns a number (the count of tracked lists the entity was removed from). Existingawait cache.invalidateEntity(...)calls that ignore the return value continue to work.getMetrics()returns real numbers. If you had asserts on the old hardcoded zeros, update them.- List values that were written without TTL keep working until manually deleted. New writes apply the schema's
ttl(orcache.defaultTTL) automatically. selectiveFieldsnow actually restricts the output. Any code that was relying on the old broken behaviour (where the option was a no-op) needs review.- Circular references now emit a
$refmarker rather than silently dropping data. Hydration consumers should handle the$reffield if they walk relation graphs.
Recommended adoption order
No data migration is required
- Turn on the connection pool first if you have concurrency pain (
poolSize: 8). - Convert one list at a time to
indexedListas needed. - Enable compression last, with a generous threshold (e.g. 4 KB), after the rest is stable.
Honest reading guide
- Run a smoke test against a local Redis before relying on this in any environment that matters.
- Pick one read path and migrate it first. Don't flip the whole app over to indexed-list in one PR.
- Wire
getMetrics()into your observability stack before traffic ramps. Hit rate is the only honest signal of whether the cache is actually paying off.