How to handle distributed cache invalidation when primary database fails over to a replica
In a primary-replica setup with Redis caching, what is the safest strategy for cache invalidation during an unplanned failover? The concern is stale data: the replica might be slightly behind, and cache entries keyed to primary-specific timestamps or LSNs could become invalid. Do you invalidate everything on failover, use versioned cache keys, or accept a brief inconsistency window? Looking for patterns that have worked in production at scale.