Class LRUCache<K,V>

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

public class LRUCache<K,V> extends ReentrantCache<K,V>
LRU (least recently used)最近最久未使用缓存 1、元素持续添加直到存满,触发 清理全部过期对象; 2、清理后缓存仍存满时,最久未被使用的对象将被移除; (此缓存基于LinkedHashMap,因此当被缓存的对象每被访问一次,这个对象的key就到链表头部) 3、优劣势: - 优势:简单、速度快;经常使用的对象,不会被被移除缓存; - 劣势:不能很快的访问缓存中不常用的对象;
See Also:
  • Constructor Details

    • LRUCache

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

    • doPrune

      protected int doPrune()
      只 清理全部过期对象,LRU的实现会交给LinkedHashMap
      Specified by:
      doPrune in class ReentrantCache<K,V>
      Returns:
      清理数据量