1. write back和write through
这里引用smartcache的关于它两的定义:
Write-through Cache Policy: The goal of write-through caching is to accelerate the read operations. All write operations go to
Primary Source (HDDs); write operations may also go to the Cache (SSDs). Thus the write operations may be slower compared to a
configuration without Write-through Cache
Write-back Cache Policy: The goal of write-back caching is to accelerate both read and write operations. Writes may be cached on the Cache (SSDs) and written to the Primary Storage (HDDs) at a later point of time.
翻译:
write-through(透写): 加速读操作,所有的写操作直接写往主存,同时也写在缓存cache中,因此写操作相对较慢。
write-back(回写):同时加速读写操作,写操作先缓存在cache中,稍后才会写到主存中去。
1.1. write-back的优缺点
优点:回写操作先将数据写到cache缓冲之中便立刻返回,不等待磁盘等存储设备IO写指令执行完毕。因为免去了等待操作较慢的IO写操作的执行,这种方式具有较高的效率。
缺点:Cache中会保存上一次写之后的数据(通常叫做脏数据),而且如果写的过程中发生了掉电,则不能确保数据切实被写入到磁盘中。