Example #1
0
 public void testConcurrencyLevel_zero() {
   CacheBuilder<Object, Object> builder = new CacheBuilder<Object, Object>();
   try {
     builder.concurrencyLevel(0);
     fail();
   } catch (IllegalArgumentException expected) {
   }
 }
Example #2
0
 public void testConcurrencyLevel_setTwice() {
   CacheBuilder<Object, Object> builder = new CacheBuilder<Object, Object>().concurrencyLevel(16);
   try {
     // even to the same value is not allowed
     builder.concurrencyLevel(16);
     fail();
   } catch (IllegalStateException expected) {
   }
 }
  private void buildCache() {
    long sizeInBytes =
        MemorySizeValue.parseBytesSizeValueOrHeapRatio(size, INDICES_CACHE_QUERY_SIZE).bytes();

    CacheBuilder<Key, Value> cacheBuilder =
        CacheBuilder.newBuilder()
            .maximumWeight(sizeInBytes)
            .weigher(new QueryCacheWeigher())
            .removalListener(this);
    cacheBuilder.concurrencyLevel(concurrencyLevel);

    if (expire != null) {
      cacheBuilder.expireAfterAccess(expire.millis(), TimeUnit.MILLISECONDS);
    }

    cache = cacheBuilder.build();
  }
 public com.google.common.cache.CacheBuilder<Object, Object> concurrencyLevel(
     int concurrencyLevel) {
   return builder.concurrencyLevel(concurrencyLevel);
 }