alibaba-druid里面的LRU缓存实现

内容从druid包里面拷贝的

package org.jsirenia.cache;

import java.util.LinkedHashMap;
import java.util.Map;
//copy from com.alibaba.druid.util.LRUCache;
public class LRUCache extends LinkedHashMap {
	private static final long serialVersionUID = 1L;
	private final int maxSize;

	public LRUCache(int maxSize) {
		this(maxSize, 16, 0.75F, false);
	}

	public LRUCache(int maxSize, int initialCapacity, float loadFactor, boolean accessOrder) {
		super(initialCapacity, loadFactor, accessOrder);
		this.maxSize = maxSize;
	}

	protected boolean removeEldestEntry(Map.Entry eldest) {
		return this.size() > this.maxSize;
	}
}

你可能感兴趣的:(java,数据结构和算法)