Write-behind
You write to the cache, and the cache passes the data to the database later, asynchronously. It's fast, but data can be lost if the cache goes down.
Example
Likes are counted in the cache and flushed to the database every 5 seconds. If the cache goes down, those 5 seconds of likes are lost.
Test yourself: Write-behind
Cache
A social network gets 80,000 «likes» per second. Losing a few isn't serious. Which write strategy does it use?
Write-back confirms in 1 ms and sends the likes to the database later, in batches. If 5 out of 80,000 are lost, nobody notices; waiting 50 ms on the database for each one couldn't keep up.
0/1
â–¶ Play