zoukankan      html  css  js  c++  java
  • Cache写机制:Writethrough与Writeback

    Writing policies

    A Write-Through cache with No-Write Allocation

    A Write-Back cache with Write Allocation

    When a system writes a datum to cache, it must at some point write that datum to backing store as well. The timing of this write is controlled by what is known as the write policy.

    There are two basic writing approaches:

    • Write-through - Write is done synchronously both to the cache and to the backing store.
    • Write-back (or Write-behind) - Writing is done only to the cache. A modified cache block is written back to the store, just before it is replaced.

    write-through同时更新cache和后端存储

    write-back 只写cache。当cache blokc要被替换时,才写到后端存储。

    Write-back cache is more complex to implement, since it needs to track which of its locations have been written over, and mark them as dirty for later writing to the backing store. The data in these locations are written back to the backing store only when they are evicted from the cache, an effect referred to as a lazy write. For this reason, a read miss in a write-back cache (which requires a block to be replaced by another) will often require two memory accesses to service: one to write the replaced data from the cache back to the store, and then one to retrieve the needed datum.

    Other policies may also trigger data write-back. The client may make many changes to a datum in the cache, and then explicitly notify the cache to write back the datum.

    Since on write operations, no actual data are needed back, there are two approaches for situations of write-misses:

    • Write allocate (aka Fetch on write) - Datum at the missed-write location is loaded to cache, followed by a write-hit operation. In this approach, write misses are similar to read-misses.
    • No-write allocate (aka Write-no-allocate, Write around) - Datum at the missed-write location is not loaded to cache, and is written directly to the backing store. In this approach, actually only system reads are being cached.

    Both write-through and write-back policies can use either of these write-miss policies, but usually they are paired in this way:[2]

    • A write-back cache uses write allocate, hoping for subsequent writes (or even reads) to the same location, which is now cached.
    • A write-through cache uses no-write allocate. Here, subsequent writes have no advantage, since they still need to be written directly to the backing store.

    Entities other than the cache may change the data in the backing store, in which case the copy in the cache may become out-of-date or stale. Alternatively, when the client updates the data in the cache, copies of those data in other caches will become stale. Communication protocols between the cache managers which keep the data consistent are known as coherency protocols.

  • 相关阅读:
    H3C BGP配置10BGP安全功能典型配置举例
    H3C BGP配置9调整和优化BGP网络典型配置举例1BGP负载分担配置
    H3C BGP配置11 BGP网络的可靠性典型配置举例1BGP GR配置
    H3C BGP配置9调整和优化BGP网络典型配置举例2BGP AddPath配置
    vue移动端适配postcsspxtorem
    .net 技术站点(转载)
    邯郸.net俱乐部
    存储过程从入门到熟练(多个存储过程完整实例及调用方法)_AX 转载
    gridview中删除记录的处理
    邯郸.NET俱乐部正式成立了
  • 原文地址:https://www.cnblogs.com/cute/p/2582916.html
Copyright © 2011-2022 走看看