Write-Back Caching 00:00:01 The customer has saved an email the database cannot yet see An email change reaches a write-back cache. The service can answer before writing the authoritative database in this design. Identify where the only new copy lives at that moment. The app is asked to change the email of user:123. Only memory is touched. The key waits in line for the database. The timer fires, or the buffer is full. The cache entry is the same as the database now. Cache and database agree until the next write. The early acknowledgement buys latency by changing the durability boundary. Choose a write log, replication policy or explicitly accepted loss window that matches the actual promise. 00:00:45 Five likes can become one database write Several updates to one counter arrive during a flush interval. A later combined value may replace several would-be writes if the required application semantics permit that collapse. The first like for post 7. Four more likes. Still one dirty key. The database gets a single write with the value 5. Coalescing final state is different from retaining each individual event. Billing, audit and unique-user counts may require evidence that a single combined row cannot reconstruct. 00:01:21 A cache dies with acknowledged work waiting Five thousand writes have been acknowledged but remain dirty. Stop the component that holds them and inspect which recovery paths contain the new values. 5,000 acknowledged writes wait for the flush. The machine stops. Memory is gone. Redis with its append-only file and the default sync every second loses about one second of writes. A copy on another machine covers a dead machine. Replication is asynchronous, so a little can still be lost. A surviving asynchronous replica might still lag. Test a host failure and a whole failure-domain loss against the stated acknowledgement policy. 00:02:01 A value changes while its older snapshot flushes The worker takes a snapshot, but a customer can update the key before the database write returns. A successful older flush must not clear the dirty marker for a newer value. The worker takes a snapshot but leaves the keys dirty. The bulk write fails. Callers are still served, and the buffer grows. At its limit the app must slow them down. The database is back. The upsert is safe to repeat. A key changed during the flush stays dirty for the next one. Associate the flush with its version and clear only completed work for that version. Retry failed writes with semantics that do not reverse a later committed update. 00:02:42 Shut down without discarding the last updates Maintenance needs to remove the cache worker. First stop admitting new dirty writes there, then drain outstanding versions and verify the durable checkpoint. New writes go to another server or get a retry answer. The worker empties the buffer and waits for the database. With nothing dirty, the process can end. Bound how long draining may take and define a safe fallback if the database remains down. A graceful stop tests the same durability promise that made the early acknowledgement possible.