当前位置: 首页>>代码示例>>Java>>正文


Java Weighers类代码示例

本文整理汇总了Java中com.googlecode.concurrentlinkedhashmap.Weighers的典型用法代码示例。如果您正苦于以下问题:Java Weighers类的具体用法?Java Weighers怎么用?Java Weighers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Weighers类属于com.googlecode.concurrentlinkedhashmap包,在下文中一共展示了Weighers类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SerializingCache

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
public SerializingCache(int capacity, ICompactSerializer3<V> serializer, String tableName, String cfName)
{
    this.serializer = serializer;

    EvictionListener<K,FreeableMemory> listener = new EvictionListener<K, FreeableMemory>()
    {
        public void onEviction(K k, FreeableMemory mem)
        {
            mem.unreference();
        }
    };
    this.map = new ConcurrentLinkedHashMap.Builder<K, FreeableMemory>()
               .weigher(Weighers.<FreeableMemory>singleton())
               .initialCapacity(capacity)
               .maximumWeightedCapacity(capacity)
               .concurrencyLevel(DEFAULT_CONCURENCY_LEVEL)
               .listener(listener)
               .build();
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:20,代码来源:SerializingCache.java

示例2: init

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
private void init() {
    if (cache == null) {
        synchronized (this) {
            if (cache == null) {
                cache = new ConcurrentLinkedHashMap.Builder<InnerQueryKey, SQLParsedState>().maximumWeightedCapacity(capacity).weigher(Weighers.singleton()).build();
            }
        }
    }
}
 
开发者ID:hellojavaer,项目名称:ddal,代码行数:10,代码来源:LRUSQLParserCache.java

示例3: PersistableCache

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
public PersistableCache(JdbcTemplate template, int size) {
    dataMap = new ConcurrentLinkedHashMap.Builder<Long, Persistable>().maximumWeightedCapacity(size).weigher(Weighers.singleton())
            .listener((id, data) -> {
                if (data.isDirty()) {
                    //如果发现数据是脏的,那么重新put一次,保证及时入库
                    LOGGER.error("脏数据从缓存中移除了:" + id);
                }
            }).build();
}
 
开发者ID:beimi,项目名称:ServerCore,代码行数:10,代码来源:PersistableCache.java

示例4: MessagesRegistry

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
public MessagesRegistry(int initialCapacity, int maxCapacity, int concurrencyLevel, @Nullable EvictionListener<Sha256Hash, Entry<T>> evictionListener) {
    final ConcurrentLinkedHashMap.Builder<Sha256Hash, Entry<T>> builder = new ConcurrentLinkedHashMap.Builder<Sha256Hash, Entry<T>>()
            .concurrencyLevel(concurrencyLevel)
            .initialCapacity(initialCapacity)
            .maximumWeightedCapacity(maxCapacity)
            .weigher(Weighers.entrySingleton());
    if (evictionListener != null) {
        builder.listener(evictionListener);
    }
    cache = builder.build();
}
 
开发者ID:btcsoft,项目名称:coinj-dash,代码行数:12,代码来源:MessagesRegistry.java

示例5: testSerializingCache

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
@Test
public void testSerializingCache() throws InterruptedException
{
    ICache<MeasureableString, IRowCacheEntry> cache = SerializingCache.create(CAPACITY, Weighers.<RefCountedMemory>singleton(), new SerializingCacheProvider.RowCacheSerializer());
    ColumnFamily cf = createCF();
    simpleCase(cf, cache);
    concurrentCase(cf, cache);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:CacheProviderTest.java

示例6: testHeapCache

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
@Test
public void testHeapCache() throws InterruptedException
{
    ICache<MeasureableString, IRowCacheEntry> cache = ConcurrentLinkedHashCache.create(CAPACITY, Weighers.<MeasureableString, IRowCacheEntry>entrySingleton());
    ColumnFamily cf = createCF();
    simpleCase(cf, cache);
    concurrentCase(cf, cache);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:9,代码来源:CacheProviderTest.java

示例7: GoogleConcurrentLruCache

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
public GoogleConcurrentLruCache(int capacity){
    if (capacity <= 0) {
        capacity = DEFAULT_CAPACITY;
    }

    cache = new ConcurrentLinkedHashMap.Builder<K, V>().maximumWeightedCapacity(capacity)
        .weigher(Weighers.singleton())
        .concurrencyLevel(DEFAULT_CONCURENCY_LEVEL)
        .build();
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:11,代码来源:GoogleConcurrentLruCache.java

示例8: testSerializingCache

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
@Test
public void testSerializingCache() throws InterruptedException
{
    ICache<MeasureableString, IRowCacheEntry> cache = SerializingCache.create(CAPACITY, Weighers.<RefCountedMemory>singleton(), new SerializingCacheProvider.RowCacheSerializer());
    CachedBTreePartition partition = createPartition();
    simpleCase(partition, cache);
    concurrentCase(partition, cache);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:9,代码来源:CacheProviderTest.java

示例9: LRUCache

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
public LRUCache(String title, int maxsize, long expiretime) {
    this.title = title;
    this.expiretime.set(expiretime);
    this.maxsize.set(maxsize);
    cache = new ConcurrentLinkedHashMap.Builder<Object, CacheItem>().maximumWeightedCapacity(maxsize).weigher(Weighers.singleton()).build();
    LRUCacheManager.regist(title, this);
}
 
开发者ID:peiliping,项目名称:excalibur,代码行数:8,代码来源:LRUCache.java

示例10: create

import com.googlecode.concurrentlinkedhashmap.Weighers; //导入依赖的package包/类
public static <K, V> ConcurrentLinkedHashCache<K, V> create(int capacity, String tableName, String cfname)
{
    ConcurrentLinkedHashMap<K, V> map = new ConcurrentLinkedHashMap.Builder<K, V>()
                                        .weigher(Weighers.<V>singleton())
                                        .initialCapacity(capacity)
                                        .maximumWeightedCapacity(capacity)
                                        .concurrencyLevel(DEFAULT_CONCURENCY_LEVEL)
                                        .build();
    return new ConcurrentLinkedHashCache<K, V>(map);
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:11,代码来源:ConcurrentLinkedHashCache.java


注:本文中的com.googlecode.concurrentlinkedhashmap.Weighers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。