本文整理汇总了Java中com.googlecode.concurrentlinkedhashmap.Weigher类的典型用法代码示例。如果您正苦于以下问题:Java Weigher类的具体用法?Java Weigher怎么用?Java Weigher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Weigher类属于com.googlecode.concurrentlinkedhashmap包,在下文中一共展示了Weigher类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SerializingCache
import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
private SerializingCache(long capacity, Weigher<RefCountedMemory> weigher, ISerializer<V> serializer)
{
this.serializer = serializer;
EvictionListener<K,RefCountedMemory> listener = new EvictionListener<K, RefCountedMemory>()
{
public void onEviction(K k, RefCountedMemory mem)
{
mem.unreference();
}
};
this.map = new ConcurrentLinkedHashMap.Builder<K, RefCountedMemory>()
.weigher(weigher)
.maximumWeightedCapacity(capacity)
.concurrencyLevel(DEFAULT_CONCURENCY_LEVEL)
.listener(listener)
.build();
}
示例2: Cache
import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
public Cache(long maxSize, Metrics metrics) {
cache = new TableBlockCache<IndexBlock>(maxSize, new Weigher<IndexBlock>() {
@Override
public int weightOf(IndexBlock indexRecord) {
return indexRecord.memory().size();
}
});
metrics.gauge("cache.indexBlock.entrySize", new Gauge<Long>() {
@Override
public Long getValue() {
return cache.totalEntrySize();
}
});
metrics.gauge("cache.indexBlock.utilizationRate", new Gauge<Double>() {
@Override
public Double getValue() {
return cache.utilizationRate();
}
});
}
示例3: Cache
import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
public Cache(long maxSize, Metrics metrics) {
cache = new TableBlockCache<TupleBlock>(maxSize, new Weigher<TupleBlock>() {
@Override
public int weightOf(TupleBlock tuple) {
return tuple.memory().size();
}
});
metrics.gauge("cache.tupleBlock.entrySize", new Gauge<Long>() {
@Override
public Long getValue() {
return cache.totalEntrySize();
}
});
metrics.gauge("cache.tupleBlock.utilizationRate", new Gauge<Double>() {
@Override
public Double getValue() {
return cache.utilizationRate();
}
});
}
示例4: TableBlockCache
import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
public TableBlockCache(long maxSize, Weigher<T> weigher) {
cache = new ConcurrentLinkedHashMap.Builder<Entry, T>().concurrencyLevel(CONCURRENCY_LEVEL).weigher(weigher)
.listener(new EvictionListener<Entry, T>() {
@Override
public void onEviction(Entry key, T value) {
totalSize.addAndGet(-(value.memory().size()));
value.memory().release();
}
}).maximumWeightedCapacity(maxSize).build();
this.maxSize = maxSize;
}
示例5: create
import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
public static <K, V> SerializingCache<K, V> create(long weightedCapacity, Weigher<RefCountedMemory> weigher, ISerializer<V> serializer)
{
return new SerializingCache<>(weightedCapacity, weigher, serializer);
}
示例6: create
import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
public static <K, V> SerializingCache<K, V> create(long weightedCapacity, Weigher<RefCountedMemory> weigher, ISerializer<V> serializer)
{
return new SerializingCache<K, V>(weightedCapacity, weigher, serializer);
}