List of usage examples for com.google.common.collect MapMaker concurrencyLevel
@Override public MapMaker concurrencyLevel(int concurrencyLevel)
From source file:sg.atom.utils._commons.bean.orika.util.HashMapUtility.java
/** * Generates a new instance of ConcurrentMap with the specified max weighted * capacity/* www .ja v a 2 s . c om*/ * * @param keyClass * @param valClass * @param capacity * @return a new instance of ConcurrentMap with the specified max weighted * capacity */ public static <K, V extends MappedTypePair<Object, Object>> ConcurrentMap<K, V> getConcurrentMap(int capacity) { MapMaker builder = new MapMaker(); return builder.concurrencyLevel(capacity).makeMap(); }
From source file:org.ttrssreader.utils.AbstractCache.java
/** * Creates a new cache instance.// w ww. ja v a 2 s. co m * * @param initialCapacity the initial element size of the cache * @param maxConcurrentThreads how many threads you think may at once access the cache; this need not be an exact * number, but it helps in fragmenting the cache properly */ public AbstractCache(int initialCapacity, int maxConcurrentThreads) { MapMaker mapMaker = new MapMaker(); mapMaker.initialCapacity(initialCapacity); // mapMaker.expiration(expirationInMinutes * 60, TimeUnit.SECONDS); mapMaker.concurrencyLevel(maxConcurrentThreads); mapMaker.softValues(); this.cache = mapMaker.makeMap(); }
From source file:com.wareninja.opensource.droidfu.cachefu.AbstractCache.java
/** * Creates a new cache instance./*from w ww . j a v a 2s.c om*/ * * @param name * a human readable identifier for this cache. Note that this value will be used to * derive a directory name if the disk cache is enabled, so don't get too creative * here (camel case names work great) * @param initialCapacity * the initial element size of the cache * @param expirationInMinutes * time in minutes after which elements will be purged from the cache (NOTE: this * only affects the memory cache, the disk cache does currently NOT handle element * TTLs!) * @param maxConcurrentThreads * how many threads you think may at once access the cache; this need not be an exact * number, but it helps in fragmenting the cache properly */ public AbstractCache(String name, int initialCapacity, long expirationInMinutes, int maxConcurrentThreads) { this.name = name; MapMaker mapMaker = new MapMaker(); mapMaker.initialCapacity(initialCapacity); mapMaker.expiration(expirationInMinutes * 60, TimeUnit.SECONDS); mapMaker.concurrencyLevel(maxConcurrentThreads); mapMaker.softValues(); this.cache = mapMaker.makeMap(); }
From source file:com.tomdignan.remoteimage.AbstractCache.java
/** * Creates a new cache instance./*from w w w. j a va2 s .c o m*/ * * @param name * a human readable identifier for this cache. Note that this value will be used to * derive a directory name if the disk cache is enabled, so don't get too creative * here (camel case names work great) * @param initialCapacity * the initial element size of the cache * @param maxConcurrentThreads * how many threads you think may at once access the cache; this need not be an exact * number, but it helps in fragmenting the cache properly */ public AbstractCache(String name, int initialCapacity, long expirationInMinutes, int maxConcurrentThreads) { this.name = name; this.expirationInMinutes = expirationInMinutes; MapMaker mapMaker = new MapMaker(); mapMaker.initialCapacity(initialCapacity); mapMaker.concurrencyLevel(maxConcurrentThreads); mapMaker.softValues(); this.cache = mapMaker.makeMap(); }
From source file:quickutils.core.image.cache.AbstractCache.java
/** * Creates a new cache instance.//from w w w .jav a2 s . c o m * * @param name * a human readable identifier for this cache. Note that this value will be used to * derive a directory name if the disk cache is enabled, so don't get too creative * here (camel case names work great) * @param initialCapacity * the initial element size of the cache * @param expirationInMinutes * time in minutes after which elements will be purged from the cache * @param maxConcurrentThreads * how many threads you think may at once access the cache; this need not be an exact * number, but it helps in fragmenting the cache properly */ public AbstractCache(String name, int initialCapacity, long expirationInMinutes, int maxConcurrentThreads) { this.name = name; this.expirationInMinutes = expirationInMinutes; MapMaker mapMaker = new MapMaker(); mapMaker.initialCapacity(initialCapacity); mapMaker.expiration(expirationInMinutes * 60, TimeUnit.SECONDS); mapMaker.concurrencyLevel(maxConcurrentThreads); mapMaker.softValues(); this.cache = mapMaker.makeMap(); }
From source file:com.codingfingers.fastimagelist.cache.AbstractCache.java
protected MapMaker createMapMaker(int initialCapacity, long expirationInMinutes, int maxConcurrentThreads) { MapMaker mapMaker = new MapMaker(); mapMaker.initialCapacity(initialCapacity); mapMaker.expiration(expirationInMinutes * 60, TimeUnit.SECONDS); mapMaker.concurrencyLevel(maxConcurrentThreads); // mapMaker.softValues(); return mapMaker; }
From source file:com.hippoapp.asyncmvp.cache.AsyncCacheStorage.java
private void initInMemoryCache(int initialCapacity, int expirationInMinutes, int maxConcurrentThreads) { MapMaker mapMaker = new MapMaker(); mapMaker.initialCapacity(initialCapacity); mapMaker.expiration(expirationInMinutes * 60, TimeUnit.SECONDS); mapMaker.concurrencyLevel(maxConcurrentThreads); mapMaker.softValues();/*ww w.j av a 2s.c o m*/ this.mCache = mapMaker.makeMap(); }
From source file:com.boardhood.mobile.cache.AbstractCache.java
/** * Creates a new cache instance./*from w ww .j av a 2s. co m*/ * * @param name * a human readable identifier for this cache. Note that this value will be used to * derive a directory name if the disk cache is enabled, so don't get too creative * here (camel case names work great) * @param initialCapacity * the initial element size of the cache * @param maxConcurrentThreads * how many threads you think may at once access the cache; this need not be an exact * number, but it helps in fragmenting the cache properly */ public AbstractCache(String name, int initialCapacity, int maxConcurrentThreads) { this.name = name; MapMaker mapMaker = new MapMaker(); mapMaker.initialCapacity(initialCapacity); mapMaker.concurrencyLevel(maxConcurrentThreads); mapMaker.softValues(); this.cache = mapMaker.makeMap(); }