I started with cache-aside since that's the most common, but they pushed back pretty fast asking about race conditions.
Start by clarifying the consistency requirements (e.g., read-after-write, eventual consistency) and the failure modes you're optimizing for. Then walk through common patterns like cache-aside, write-through, write-behind, and double-delete, explaining their trade-offs in terms of consistency, latency, and complexity. Conclude with how you'd choose based on business needs and how you'd handle reconciliation and monitoring.
Pro tip: Emphasize that perfect consistency between Redis and the database is often unnecessary; instead, focus on bounded staleness and idempotent operations. Mention that you'd instrument cache hit ratios and inconsistency detection to make data-driven decisions.
Ask about the acceptable staleness window and whether the system needs strong consistency or can tolerate eventual consistency. This determines which patterns are viable.
Discuss cache-aside, write-through, write-behind, and refresh-ahead, noting how each handles writes and reads and their impact on consistency.
Compare patterns on consistency, latency, complexity, and failure resilience. For example, write-behind improves write latency but risks data loss on Redis failure.
Explain how to handle Redis outages, network partitions, and race conditions (e.g., using versioning, locks, or idempotent writes).
Describe mechanisms to detect and repair inconsistencies, such as periodic jobs, change data capture, or TTL-based expiry, and how to monitor cache effectiveness.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.