Cache学习笔记

    今天看了一下有关cache的科普文章,很是受益,其中的关键知识点摘抄下来,日后好多加复习与揣摩。

 

     Least Frequently Used (LFU):

     I am Least Frequently used; I count how often an entry is needed by incrementing a counter associated with each entry.

I remove the entry with least frequently used counter first am not that fast and I am not that good in adaptive actions (which means that it keeps the entries which is really needed and discard the ones that aren’t needed for the longest period based on the access pattern or in other words the request pattern)

     LFU机制计算entry被使用的数量,去除最少使用的entry, 速度不是很快。

 

     Least Recently Used (LRU):

     I am Least Recently Used cache algorithm; I remove the least recently used items first. The one that wasn’t used for a longest time.

I require keeping track of what was used when, which is expensive if one wants to make sure that I always discards the least recently used item.
Web browsers use me for caching. New items are placed into the top of the cache. When the cache exceeds its size limit, I will discard items from the bottom. The trick is that whenever an item is accessed, I place at the top.

So items which are frequently accessed tend to stay in the cache. There are two ways to implement me either an array or a linked list (which will have the least recently used entry at the back and the recently used at the front).

I am fast and I am adaptive in other words I can adopt to data access pattern, I have a large family which completes me and they are even better than me (I do feel jealous some times but it is ok) some of my family member are (LRU2 and 2Q) (they were implemented in order to improve LRU caching

     LRU机制去除最近最少使用的entry,最长时间没有被用到的将被删除。LRU记录entry被使用的情况。浏览器经常使用LRU机制作为缓存,新加入的entry被放在最上面,可以通过数组或是linked list实现LRU机制。

 

     First in First out (FIFO):

     I am first in first out; I am a low-overhead algorithm I require little effort for managing the cache entries. The idea is that I keep track of all the cache entries in a queue, with the most recent entry at the back, and the earliest entry in the front. When there is no place and an entry needs to be replaced, I will remove the entry at the front of the queue (the oldest entry) and replaced with the current fetched entry. I am fast but I am not adaptive

     FIFO机制,开销很低,先进先出,速度很快。

 

     另外还有以时间为标准的,以及以上几种的改良和平衡类型。

 

     一般的cache产品应该有如下功能:

 

1-POJO Caching
2-HTTP Response Caching
3-JSP Caching
4-ORM Data Access Caching

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值