com.googlecode.concurrentlinkedhashmap.Weighers Java Examples
The following examples show how to use
com.googlecode.concurrentlinkedhashmap.Weighers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConcurrentLinkedHashMapWrapper.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
public ConcurrentLinkedHashMapWrapper(long size) { if (size <= 0) { throw new IllegalArgumentException("Cache max capacity should be positive: " + size); } this.map = new ConcurrentLinkedHashMap.Builder<T, R>() .concurrencyLevel(DEFAULT_CONCURRENCY_LEVEL) .maximumWeightedCapacity(size) .weigher(Weighers.singleton()) .build(); }
Example #2
Source File: ConcurrentLinkedHashMapWrapper.java From Sentinel with Apache License 2.0 | 5 votes |
public ConcurrentLinkedHashMapWrapper(long size) { if (size <= 0) { throw new IllegalArgumentException("Cache max capacity should be positive: " + size); } this.map = new ConcurrentLinkedHashMap.Builder<T, R>() .concurrencyLevel(DEFAULT_CONCURRENCY_LEVEL) .maximumWeightedCapacity(size) .weigher(Weighers.singleton()) .build(); }
Example #3
Source File: LRUSQLParserCache.java From ddal with Apache License 2.0 | 5 votes |
private void init() { if (cache == null) { synchronized (this) { if (cache == null) { cache = new ConcurrentLinkedHashMap.Builder<InnerQueryKey, SQLParsedState>().maximumWeightedCapacity(capacity).weigher(Weighers.singleton()).build(); } } } }
Example #4
Source File: FormatFunction.java From ddal with Apache License 2.0 | 5 votes |
@Override protected Map initialValue() { return new ConcurrentLinkedHashMap.Builder<String, Map>()// .maximumWeightedCapacity(100)// .weigher(Weighers.singleton())// .build(); }
Example #5
Source File: PersistableCache.java From ServerCore with Apache License 2.0 | 5 votes |
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(); }
Example #6
Source File: GoogleConcurrentLruCache.java From tddl with Apache License 2.0 | 5 votes |
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(); }
Example #7
Source File: GoogleConcurrentLruCache.java From tddl with Apache License 2.0 | 5 votes |
public GoogleConcurrentLruCache(int capacity, EvictionListener<K, V> listener){ if (capacity <= 0) { capacity = DEFAULT_CAPACITY; } cache = new ConcurrentLinkedHashMap.Builder<K, V>().maximumWeightedCapacity(capacity) .weigher(Weighers.singleton()) .concurrencyLevel(DEFAULT_CONCURENCY_LEVEL) .listener(listener) .build(); }
Example #8
Source File: CacheProviderTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@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); }
Example #9
Source File: CacheServiceJDKImpl.java From kkFileView with Apache License 2.0 | 4 votes |
@Override public void initPDFCachePool(Integer capacity) { pdfCache = new ConcurrentLinkedHashMap.Builder<String, String>() .maximumWeightedCapacity(capacity).weigher(Weighers.singleton()) .build(); }
Example #10
Source File: CacheServiceJDKImpl.java From kkFileView with Apache License 2.0 | 4 votes |
@Override public void initIMGCachePool(Integer capacity) { imgCache = new ConcurrentLinkedHashMap.Builder<String, List<String>>() .maximumWeightedCapacity(capacity).weigher(Weighers.singleton()) .build(); }
Example #11
Source File: CacheServiceJDKImpl.java From kkFileView with Apache License 2.0 | 4 votes |
@Override public void initPdfImagesCachePool(Integer capacity) { pdfImagesCache = new ConcurrentLinkedHashMap.Builder<String, Integer>() .maximumWeightedCapacity(capacity).weigher(Weighers.singleton()) .build(); }