All Questions
Caching hard

You need to invalidate a cache key after a DB write. If the DB commit succeeds but the Redis call fails, data is inconsistent. How does the Transactional Outbox pattern solve this?

  1. A The application is re-architected to perform every write to the Redis cluster first, followed by a secondary commit to the primary database instance.
  2. B The system utilizes a localized Two-Phase Commit protocol that ensures the Redis and Database writes are either both successful or both discarded.
  3. C It inserts a 'cache_invalidation_event' into a DB table within the same transaction as the write, allowing a background process to reliably retry.
  4. D The failure is ignored by the application logic, as it relies on the relatively short Time-To-Live (TTL) of the cache entry to eventually restore consistency.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions