Write-through
You write to the cache, and the cache writes to the database right away. Writing is slower, but the cache never goes stale.
Example
You change your email: it's saved to the cache and the database at the same moment. It takes a bit longer, but anyone who reads it sees the new one.
Test yourself: Write-through
Cache
With write-through, data is written to the cache and the database at the same time.
Both always match: reading from the cache gives the same as reading from the database, in 1 ms instead of 50.
0/1
â–¶ Play