intermediateTop 30 Scenario-Based Questions
How do you handle cache invalidation when multiple services can update the same data?
Cache invalidation is the hardest problem. Strategies: 1) Event-driven invalidation: when any service updates product, publish ProductUpdated event to message bus (Kafka). All services subscribed delete their cached product version. 2) TTL-based staleness: accept up to 5-minute stale data. Set TTL=300. Auto-expired even if event missed. 3) Cache versioning: store version with cached object. On upd
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response