Class LFUCache<K,V>

java.lang.Object
com.xxl.tool.cache.impl.ReentrantCache<K,V>
com.xxl.tool.cache.impl.LFUCache<K,V>
All Implemented Interfaces:
Cache<K,V>, Serializable

public class LFUCache<K,V> extends ReentrantCache<K,V>
LFU(least frequently used) 最少使用率缓存 1、元素持续添加直到存满,触发 清理全部过期对象; 2、清理后缓存仍存满时,清除最少访问(访问计数最小)的对象;并将其他对象的访问数减去这个最小访问数,以便新对象进入后可以公平计数。 3、优劣势: - 优势,热点数据可以常驻内存; - 劣势,复杂度较高;
See Also:
  • Constructor Details

    • LFUCache

      public LFUCache(int capacity, long timeout, boolean expireType)
  • Method Details

    • doPrune

      protected int doPrune()
      1、清理全部过期对象 2、清理后缓存仍存满时,清除最少访问(访问计数最小)的对象;并将其他对象的访问数减去这个最小访问数,以便新对象进入后可以公平计数。
      Specified by:
      doPrune in class ReentrantCache<K,V>
      Returns:
      清理数据量