ConcurrentLinkedHashMapJava高性能集合類
ConcurrentLinkedHashMap是java.util.LinkedHashMap的一個(gè)高性能實(shí)現(xiàn)。主要用于軟件緩存。
示例代碼:
EvictionListener<K, V> listener = new EvictionListener<K, V>() {
@Override public void onEviction(K key, V value) {
System.out.println("Evicted key=" + key + ", value=" + value);
}
};
ConcurrentMap<K, V> cache = new ConcurrentLinkedHashMap.Builder<K, V>()
.maximumWeightedCapacity(1000)
.listener(listener)
.build();評(píng)論
圖片
表情
