Cache

wiki: http://en.wikipedia.org/wiki/Cache_(computing)


1、cache原理


不多解释。参考链接:http://www.doc88.com/p-549882154113.html


2、写策略

   

  • Write-through - Write is done synchronously both to the cache and to the backing store.
  • Write-back (or Write-behind) - Initially, writing is done only to the cache. The write to the backing store is postponed until the cache blocks containing the data are about to be modified/replaced by new content.

写回模式实现上更复杂,因为需要跟踪哪个地址被修改,并且标记为dirty以备将来写入到主存中。仅仅在这些地址的数据被交换出cache时才写入主存,这也被称为lazy write。因为这个原因,针对写回cache的read miss往往需要两份:一份用于将替换的数据写回主存,一份用于获取需要的数据。

也有其他策略触发数据的写回。client可能大量修改了cache中的数据,并显示的通知cache写回数据。

http://blog.chinaunix.net/uid-21091200-id-1830760.html

该文解释了三种策略:写透、写回、写一次。

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-allocateWrite around) - Datum at the missed-write location is not loaded to cache, and is written directly to the backing store. In this approach, only system reads are being cached.
虽然写透和写回策略可以使用以上任一write miss策略,但实际他们是成对使用的:
  • 写回策略使用write allocate, 以便后续写或读改地址的内存,已提前做好cache。
  • 写透策略使用no-write allocate. 直接写到主存,无需cache,只有读的时候需要cache。

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.


3、cache算法

tbd


4、cache一致性

tbd


5、cache染色

tbd




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值