Write-through-write is do synchronously both to the cache and to the backing store.
Write-back (or Write-behind) –writing is done with the cache. A modified cache block was written back to the store and just before it is replaced.
Write-through (direct write mode) writes cached cache and back-end storage while data is being updated. The advantage of this pattern is that it is easy to operate, and the disadvantage is that data modifications need to be written to storage at the same time, and data writes slowly.
Write-back (write-back mode) writes cache caching only when data is updated. Cached data that is modified is written to the back-end store only when the data is replaced with the cache. The advantage of this pattern is that the data is written faster because there is no need for write storage; The disadvantage is that once the updated data is not written to storage, the system will lose power and the data cannot be recovered.
How to deal with write-misses write missing
For a write operation, there is a situation where the write cache missing data is present, and there are two ways to handle it:
Write Allocate (aka Fetch on Write) –datum at the Missed-write location are loaded to cache, followed by a write-hit opera tion. In the approach, write misses are similar to read-misses.
No-write Allocate (aka Write-no-allocate, write around) –datum at the Missed-write location are not loaded to cache, and I s written directly to the backing store. In this approach, actually only system reads are being cached.
Write allocate reads the write location into the cache and then takes a write-hit (cache hit write) operation. Write-missing operations are similar to read-missing operations.
The No-write allocate does not read the write location into the cache, but writes the data directly to the store. In this way, only read operations are cached.
Either Write-through or write-back can use one of the two ways of writing missing. It is usually write-back to use the Write allocate method, and Write-through no-write allocate; Because write allocate with Write-back can improve performance when writing to the same cache multiple times , but for Write-through it doesn't help.
Process flowchart
Write-through Mode processing process:
A Write-through cache with No-write allocation
Write-back Mode processing process:
A Write-back cache with Write allocation