jargon

Comparison

Write-behind cachevsWrite-through cache

Write-behind cache

you write to the cache, return success immediately, and let a background flush push the batch down to the database later.

Writes land in the cache and are persisted asynchronously, usually coalesced into batches. It absorbs write spikes and can collapse many updates of the same key into one store write, which is why counters and metrics use it. The exposure is real data loss: anything acknowledged but not yet flushed dies with the process.

1 write2 ok3 flush laterAppCacheDatabase
Full entry →

Write-through cache

every write goes into the cache and the database in the same call, so the cached copy is never behind the row.

Writes are applied to the cache and the backing store synchronously before the call returns. It keeps the cache consistent with the store and makes subsequent reads cheap, at the cost of adding the cache write to every write's latency. It also caches things nobody will read, which on a write-heavy table is pure waste.

1 write2 to the store3 okAppCacheDatabase
Full entry →

Related comparisons