Java Code Examples for com.github.benmanes.caffeine.cache.Caffeine

The following examples show how to use com.github.benmanes.caffeine.cache.Caffeine. These examples are extracted from open source projects. 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 Project: nifi   Source File: CachingSchemaRegistryClient.java    License: Apache License 2.0 6 votes vote down vote up
public CachingSchemaRegistryClient(final SchemaRegistryClient toWrap, final int cacheSize, final long expirationNanos) {
    this.client = toWrap;

    nameCache = Caffeine.newBuilder()
            .maximumSize(cacheSize)
            .expireAfterWrite(Duration.ofNanos(expirationNanos))
            .build(client::getSchema);
    nameVersionCache = Caffeine.newBuilder()
            .maximumSize(cacheSize)
            .expireAfterWrite(Duration.ofNanos(expirationNanos))
            .build(key -> client.getSchema(key.getLeft(), key.getRight()));
    idCache = Caffeine.newBuilder()
            .maximumSize(cacheSize)
            .expireAfterWrite(Duration.ofNanos(expirationNanos))
            .build(client::getSchema);
}
 
Example 2
Source Project: caffeine   Source File: CacheEvictionTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testEviction_maxSize() {
  CountingRemovalListener<Integer, Integer> removalListener = countingRemovalListener();
  IdentityLoader<Integer> loader = identityLoader();
  LoadingCache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder()
      .maximumSize(MAX_SIZE)
      .executor(MoreExecutors.directExecutor())
      .removalListener(removalListener), loader);
  for (int i = 0; i < 2 * MAX_SIZE; i++) {
    cache.getUnchecked(i);
    assertTrue(cache.size() <= MAX_SIZE);
  }

  assertEquals(MAX_SIZE, cache.size());
  assertEquals(MAX_SIZE, removalListener.getCount());
  CacheTesting.checkValidState(cache);
}
 
Example 3
Source Project: caffeine   Source File: CacheLoadingTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testBulkLoadError() throws ExecutionException {
  Error e = new Error();
  CacheLoader<Object, Object> loader = errorLoader(e);
  LoadingCache<Object, Object> cache = CaffeinatedGuava.build(Caffeine.newBuilder()
      .recordStats(), bulkLoader(loader));
  CacheStats stats = cache.stats();
  assertEquals(0, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());

  try {
    cache.getAll(asList(new Object()));
    fail();
  } catch (ExecutionError expected) {
    assertSame(e, expected.getCause());
  }
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
 
Example 4
Source Project: J2Cache   Source File: CaffeineProvider.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 返回对 Caffeine cache 的 封装
 * @param region region name
 * @param size   max cache object size in memory
 * @param expire cache object expire time in millisecond
 *               if this parameter set to 0 or negative numbers
 *               means never expire
 * @param listener  j2cache cache listener
 * @return CaffeineCache
 */
private CaffeineCache newCaffeineCache(String region, long size, long expire, CacheExpiredListener listener) {
    Caffeine<Object, Object> caffeine = Caffeine.newBuilder();
    caffeine = caffeine.maximumSize(size)
        .removalListener((k,v, cause) -> {
            /*
             * 程序删除的缓存不做通知处理,因为上层已经做了处理
             * 当缓存数据不是因为手工删除和超出容量限制而被删除的情况,就需要通知上层侦听器
             */
            if(cause != RemovalCause.EXPLICIT && cause != RemovalCause.REPLACED && cause != RemovalCause.SIZE)
                listener.notifyElementExpired(region, (String)k);
        });
    if (expire > 0) {
        caffeine = caffeine.expireAfterWrite(expire, TimeUnit.SECONDS);
    }
    com.github.benmanes.caffeine.cache.Cache<String, Object> loadingCache = caffeine.build();
    return new CaffeineCache(loadingCache, size, expire);
}
 
Example 5
Source Project: caffeine   Source File: NullCacheTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testGet_expireAfterAccess() {
  // Guava sends a notification with SIZE as the removal cause by redefining 0 expiration as
  // a maximum size of zero. This is not done as expiration can be dynamically updated

  Object computed = new Object();
  LoadingCache<Object, Object> cache = CaffeinatedGuava.build(Caffeine.newBuilder()
      .executor(MoreExecutors.directExecutor())
      .expireAfterAccess(0, SECONDS)
      .removalListener(listener),
      constantLoader(computed));

  Object key = new Object();
  assertSame(computed, cache.getUnchecked(key));
  RemovalNotification<Object, Object> notification = listener.remove();
  assertSame(key, notification.getKey());
  assertSame(computed, notification.getValue());
  assertSame(RemovalCause.EXPIRED, notification.getCause());
  assertTrue(listener.isEmpty());
  checkEmpty(cache);
}
 
Example 6
Source Project: caffeine   Source File: NullCacheTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testGet_runtimeException() {
  final RuntimeException e = new RuntimeException();
  LoadingCache<Object, Object> map = CaffeinatedGuava.build(Caffeine.newBuilder()
      .maximumSize(0)
      .removalListener(listener),
      exceptionLoader(e));

  try {
    map.getUnchecked(new Object());
    fail();
  } catch (UncheckedExecutionException uee) {
    assertSame(e, uee.getCause());
  }
  assertTrue(listener.isEmpty());
  checkEmpty(map);
}
 
Example 7
Source Project: caffeine   Source File: CacheBuilderGwtTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testInvalidateAll() {
  Cache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder());

  cache.put(654, 2675);
  cache.put(2456, 56);
  cache.put(2, 15);

  cache.invalidateAll();
  assertFalse(cache.asMap().containsKey(654));
  assertFalse(cache.asMap().containsKey(2456));
  assertFalse(cache.asMap().containsKey(2));

  cache.put(654, 2675);
  cache.put(2456, 56);
  cache.put(2, 15);
  cache.put(1, 3);

  cache.invalidateAll(ImmutableSet.of(1, 2));

  assertFalse(cache.asMap().containsKey(1));
  assertFalse(cache.asMap().containsKey(2));
  assertTrue(cache.asMap().containsKey(654));
  assertTrue(cache.asMap().containsKey(2456));
}
 
Example 8
Source Project: caffeine   Source File: MetricsStatsCounterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void metrics() {
  // Use a registry that is exported using a Reporter (via console, JMX, Graphite, etc)
  MetricRegistry registry = new MetricRegistry();

  // Create the cache with a dedicated, uniquely named stats counter
  LoadingCache<Integer, Integer> cache = Caffeine.newBuilder()
      .recordStats(() -> new MetricsStatsCounter(registry, "example"))
      .build(key -> key);

  // Perform application work
  for (int i = 0; i < 4; i++) {
    cache.get(1);
  }

  // Statistics can be queried and reported on
  assertThat(cache.stats().hitCount(), is(3L));
  assertThat(registry.counter("example.hits").getCount(), is(3L));
}
 
Example 9
Source Project: lucene-solr   Source File: BlockDirectoryCache.java    License: Apache License 2.0 6 votes vote down vote up
public BlockDirectoryCache(BlockCache blockCache, String path, Metrics metrics, boolean releaseBlocks) {
  this.blockCache = blockCache;
  this.path = path;
  this.metrics = metrics;
      
  names = Caffeine.newBuilder().maximumSize(50000).build();
  
  if (releaseBlocks) {
    keysToRelease = Collections.newSetFromMap(new ConcurrentHashMap<BlockCacheKey,Boolean>(1024, 0.75f, 512));
    blockCache.setOnRelease(new OnRelease() {
      
      @Override
      public void release(BlockCacheKey key) {
        keysToRelease.remove(key);
      }
    });
  }
}
 
Example 10
Source Project: genie   Source File: AgentConfigurationServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param agentConfigurationProperties the properties
 * @param environment the environment
 */
public AgentConfigurationServiceImpl(
    final AgentConfigurationProperties agentConfigurationProperties,
    final Environment environment
) {
    this.agentConfigurationProperties = agentConfigurationProperties;
    this.environment = environment;

    this.agentPropertiesPattern = Pattern.compile(
        this.agentConfigurationProperties.getAgentPropertiesFilterPattern(),
        Pattern.CASE_INSENSITIVE
    );

    // Use a cache to re-compute agent properties periodically, rather than for every request.
    this.cache = Caffeine
        .newBuilder()
        .expireAfterWrite(this.agentConfigurationProperties.getCacheExpirationInterval())
        .refreshAfterWrite(this.agentConfigurationProperties.getCacheRefreshInterval())
        .initialCapacity(1)
        .build(this::loadProperties);
}
 
Example 11
Source Project: prebid-server-java   Source File: ConditionalLogger.java    License: Apache License 2.0 6 votes vote down vote up
public ConditionalLogger(String key, Logger logger) {
    this.key = key; // can be null
    this.logger = Objects.requireNonNull(logger);

    messageToCount = Caffeine.newBuilder()
            .maximumSize(CACHE_MAXIMUM_SIZE)
            .expireAfterWrite(EXPIRE_CACHE_DURATION, TimeUnit.HOURS)
            .<String, AtomicInteger>build()
            .asMap();

    messageToWait = Caffeine.newBuilder()
            .maximumSize(CACHE_MAXIMUM_SIZE)
            .expireAfterWrite(EXPIRE_CACHE_DURATION, TimeUnit.HOURS)
            .<String, Long>build()
            .asMap();
}
 
Example 12
Source Project: metron   Source File: GenericEnrichmentBolt.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext topologyContext,
                    OutputCollector collector) {
  super.prepare(conf, topologyContext, collector);
  this.collector = collector;
  if (this.maxCacheSize == null)
    throw new IllegalStateException("MAX_CACHE_SIZE_OBJECTS_NUM must be specified");
  if (this.maxTimeRetain == null)
    throw new IllegalStateException("MAX_TIME_RETAIN_MINUTES must be specified");
  if (this.adapter == null)
    throw new IllegalStateException("Adapter must be specified");
  loader = key -> adapter.enrich(key);
  cache = Caffeine.newBuilder().maximumSize(maxCacheSize)
          .expireAfterWrite(maxTimeRetain, TimeUnit.MINUTES)
          .build(loader);
  boolean success = adapter.initializeAdapter(getConfigurations().getGlobalConfig());
  if (!success) {
    LOG.error("[Metron] GenericEnrichmentBolt could not initialize adapter");
    throw new IllegalStateException("Could not initialize adapter...");
  }
  perfLog = new PerformanceLogger(() -> getConfigurations().getGlobalConfig(), GenericEnrichmentBolt.Perf.class.getName());
  initializeStellar();
}
 
Example 13
Source Project: caffeine   Source File: CacheEvictionTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testEviction_overweight() {
  // test weighted lru within a single segment
  IdentityLoader<Integer> loader = identityLoader();
  LoadingCache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder()
      .executor(MoreExecutors.directExecutor())
      .maximumWeight(45)
      .weigher(intKeyWeigher()), loader);
  CacheTesting.warmUp(cache, 0, 10);
  Set<Integer> keySet = cache.asMap().keySet();
  assertThat(keySet).containsExactly(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);

  // add an at-the-maximum-weight entry
  getAll(cache, asList(45));
  CacheTesting.drainRecencyQueues(cache);
  assertThat(keySet).containsExactly(0, 45);

  // add an over-the-maximum-weight entry
  getAll(cache, asList(46));
  CacheTesting.drainRecencyQueues(cache);
  assertThat(keySet).contains(0);
}
 
Example 14
Source Project: caffeine   Source File: CacheBuilderGwtTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testLoader() throws ExecutionException {

    final Cache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder());

    Callable<Integer> loader = new Callable<Integer>() {
      private int i = 0;

      @Override
      public Integer call() throws Exception {
        return ++i;
      }
    };

    cache.put(0, 10);

    assertEquals(Integer.valueOf(10), cache.get(0, loader));
    assertEquals(Integer.valueOf(1), cache.get(20, loader));
    assertEquals(Integer.valueOf(2), cache.get(34, loader));

    cache.invalidate(0);
    assertEquals(Integer.valueOf(3), cache.get(0, loader));

    cache.put(0, 10);
    cache.invalidateAll();
    assertEquals(Integer.valueOf(4), cache.get(0, loader));
  }
 
Example 15
Source Project: centraldogma   Source File: RepositoryCache.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
public RepositoryCache(String cacheSpec, MeterRegistry meterRegistry) {
    this.cacheSpec = requireNonNull(validateCacheSpec(cacheSpec), "cacheSpec");
    requireNonNull(meterRegistry, "meterRegistry");

    final Caffeine<Object, Object> builder = Caffeine.from(cacheSpec);
    if (cacheSpec.contains("maximumWeight=")) {
        builder.weigher((Weigher<CacheableCall, Object>) CacheableCall::weigh);
    }
    cache = builder.recordStats()
                   .buildAsync((key, executor) -> {
                       logger.debug("Cache miss: {}", key);
                       return key.execute();
                   });

    CaffeineCacheMetrics.monitor(meterRegistry, cache, "repository");
}
 
Example 16
Source Project: caffeine   Source File: CacheBuilderGwtTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testAsMap_containsKey() {
  Cache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder()
      .expireAfterWrite(20000, TimeUnit.MILLISECONDS)
      .executor(MoreExecutors.directExecutor())
      .ticker(fakeTicker::read));

  cache.put(654, 2675);
  fakeTicker.advance(10000, TimeUnit.MILLISECONDS);
  cache.put(2456, 56);
  cache.put(2, 15);

  fakeTicker.advance(10001, TimeUnit.MILLISECONDS);

  assertTrue(cache.asMap().containsKey(2));
  assertTrue(cache.asMap().containsKey(2456));
  assertFalse(cache.asMap().containsKey(654));
}
 
Example 17
Source Project: caffeine   Source File: NullCacheTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testGet_computeNull() {
  LoadingCache<Object, Object> cache = CaffeinatedGuava.build(Caffeine.newBuilder()
      .maximumSize(0)
      .removalListener(listener),
      constantLoader(null));

  try {
    cache.getUnchecked(new Object());
    fail();
  } catch (InvalidCacheLoadException e) { /* expected */}

  assertTrue(listener.isEmpty());
  checkEmpty(cache);
}
 
Example 18
Source Project: caffeine   Source File: CacheBuilderTest.java    License: Apache License 2.0 5 votes vote down vote up
@GwtIncompatible("maximumWeight")
public void testMaximumSize_andWeight() {
  Caffeine<Object, Object> builder = Caffeine.newBuilder().maximumSize(16);
  try {
    builder.maximumWeight(16);
    fail();
  } catch (IllegalStateException expected) {}
}
 
Example 19
Source Project: cache2k-benchmark   Source File: CaffeineTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
	Cache c =
		Caffeine.newBuilder().maximumWeight(1000).weigher(new Weigher<Object, Object>() {
			@Override
			public int weigh(final Object key, final Object value) {
				return value.hashCode() & 0x7f;
			}
		}).build();
	c.put(1, 123);
	c.put(1, 512);
	c.put(1, 0);
}
 
Example 20
Source Project: kaif   Source File: UtilConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public CacheManager zoneInfoCacheManager() {
  Caffeine<Object, Object> cacheBuilder = Caffeine.newBuilder()
      .expireAfterWrite(10, TimeUnit.MINUTES)
      .maximumSize(2000);
  CaffeineCacheManager cacheManager = new CaffeineCacheManager("ZoneInfo");
  cacheManager.setCaffeine(cacheBuilder);
  return cacheManager;
}
 
Example 21
Source Project: caffeine   Source File: CacheBuilderTest.java    License: Apache License 2.0 5 votes vote down vote up
@GwtIncompatible("maximumWeight")
public void testMaximumWeight_negative() {
  Caffeine<Object, Object> builder = Caffeine.newBuilder();
  try {
    builder.maximumWeight(-1);
    fail();
  } catch (IllegalArgumentException expected) {}
}
 
Example 22
Source Project: metron   Source File: BaseStellarProcessor.java    License: Apache License 2.0 5 votes vote down vote up
static Cache<String, StellarCompiler.Expression> createCache( int cacheSize
                                                     , int expiryTime
                                                     , TimeUnit expiryUnit
                                                     ) {
  CacheLoader<String, StellarCompiler.Expression> loader = key -> compile(key);
  return Caffeine.newBuilder()
                 .maximumSize(cacheSize)
                 .expireAfterAccess(expiryTime, expiryUnit)
                 .build(loader);
}
 
Example 23
Source Project: caffeine   Source File: WriteBehindCacheWriterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void givenMultipleCacheUpdatesOnSameKey_writeBehindIsCalledWithMostRecentTime() {
  AtomicBoolean writerCalled = new AtomicBoolean(false);
  AtomicInteger numberOfEntries = new AtomicInteger(0);
  AtomicReference<ZonedDateTime> timeInWriteBehind = new AtomicReference<>();

  // Given this cache...
  Cache<Long, ZonedDateTime> cache = Caffeine.newBuilder()
      .writer(new WriteBehindCacheWriter.Builder<Long, ZonedDateTime>()
          .bufferTime(1, TimeUnit.SECONDS)
          .coalesce(BinaryOperator.maxBy(ZonedDateTime::compareTo))
          .writeAction(entries -> {
            // We might get here before the cache has been written to,
            // so just wait for the next time we are called
            if (entries.isEmpty()) {
              return;
            }

            numberOfEntries.set(entries.size());
            ZonedDateTime zonedDateTime = entries.values().iterator().next();
            timeInWriteBehind.set(zonedDateTime);
            writerCalled.set(true);
          }).build())
      .build();

  // When these cache updates happen ...
  cache.put(1L, ZonedDateTime.of(2016, 6, 26, 8, 0, 0, 0, ZoneId.systemDefault()));
  cache.put(1L, ZonedDateTime.of(2016, 6, 26, 8, 0, 0, 100, ZoneId.systemDefault()));
  cache.put(1L, ZonedDateTime.of(2016, 6, 26, 8, 0, 0, 300, ZoneId.systemDefault()));
  ZonedDateTime mostRecentTime = ZonedDateTime.of(
      2016, 6, 26, 8, 0, 0, 500, ZoneId.systemDefault());
  cache.put(1L, mostRecentTime);

  // Then the write behind action gets 1 entry to write with the most recent time
  Awaitility.await().untilTrue(writerCalled);
  Assert.assertEquals(1, numberOfEntries.intValue());
  Assert.assertEquals(mostRecentTime, timeInWriteBehind.get());
}
 
Example 24
Source Project: java-technology-stack   Source File: CaffeineCacheManagerTests.java    License: MIT License 5 votes vote down vote up
@Test
public void changeCaffeineRecreateCache() {
	CaffeineCacheManager cm = new CaffeineCacheManager("c1");
	Cache cache1 = cm.getCache("c1");

	Caffeine<Object, Object> caffeine = Caffeine.newBuilder().maximumSize(10);
	cm.setCaffeine(caffeine);
	Cache cache1x = cm.getCache("c1");
	assertTrue(cache1x != cache1);

	cm.setCaffeine(caffeine); // Set same instance
	Cache cache1xx = cm.getCache("c1");
	assertSame(cache1x, cache1xx);
}
 
Example 25
public CaffeineBasedLoadBalancerCacheManager(String cacheName,
		LoadBalancerCacheProperties properties) {
	super(cacheName);
	if (!StringUtils.isEmpty(properties.getCaffeine().getSpec())) {
		setCacheSpecification(properties.getCaffeine().getSpec());
	}
	else {
		setCaffeine(Caffeine.newBuilder().initialCapacity(properties.getCapacity())
				.expireAfterWrite(properties.getTtl()).softValues());
	}

}
 
Example 26
public CachingConnectionStatusAnalyticsEngine(FlowManager flowManager, ComponentStatusRepository statusRepository,
        StatusAnalyticsModelMapFactory statusAnalyticsModelMapFactory,
        long predictionIntervalMillis, long queryIntervalMillis, String scoreName, double scoreThreshold) {

    super(flowManager, statusRepository,  statusAnalyticsModelMapFactory, predictionIntervalMillis,
                       queryIntervalMillis, scoreName, scoreThreshold);
    this.cache = Caffeine.newBuilder()
            .expireAfterAccess(5, TimeUnit.MINUTES)
            .build();
}
 
Example 27
Source Project: caffeine   Source File: CacheLoadingTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * On a concurrent computation that returns null, all threads should get an
 * InvalidCacheLoadException, with the loader only called once. The result should not be cached
 * (a later request should call the loader again).
 */
private static void testConcurrentLoadingNull(Caffeine<Object, Object> builder)
    throws InterruptedException {

  int count = 10;
  final AtomicInteger callCount = new AtomicInteger();
  final CountDownLatch startSignal = new CountDownLatch(count + 1);

  LoadingCache<String, String> cache = CaffeinatedGuava.build(builder,
      new CacheLoader<String, String>() {
        @Override public String load(String key) {
          callCount.incrementAndGet();
          assertTrue(Uninterruptibles.awaitUninterruptibly(startSignal, 300, TimeUnit.SECONDS));
          return null;
        }
      });

  List<Object> result = doConcurrentGet(cache, "bar", count, startSignal);

  assertEquals(count, callCount.get());
  for (int i = 0; i < count; i++) {
    assertTrue(result.get(i) instanceof InvalidCacheLoadException);
  }

  // subsequent calls should call the loader again, not get the old exception
  try {
    cache.getUnchecked("bar");
    fail();
  } catch (InvalidCacheLoadException expected) {
  }
  assertEquals(count + 1, callCount.get());
}
 
Example 28
Source Project: caffeine   Source File: CacheLoadingTest.java    License: Apache License 2.0 5 votes vote down vote up
private static void testConcurrentLoading(Caffeine<Object, Object> builder)
    throws InterruptedException {
  testConcurrentLoadingDefault(builder);
  testConcurrentLoadingNull(builder);
  testConcurrentLoadingUncheckedException(builder);
  testConcurrentLoadingCheckedException(builder);
}
 
Example 29
Source Project: aion   Source File: AccountManager.java    License: MIT License 5 votes vote down vote up
public AccountManager(Logger log) {
    logger = log;
    if (logger != null) {
        logger.debug("<account-manager init>");
    }

    accounts = Caffeine.newBuilder()
        .maximumSize(ACCOUNT_CACHE_SIZE)
        .expireAfterWrite(1, TimeUnit.DAYS)
        .build();
}
 
Example 30
Source Project: caffeine   Source File: PopulatedCachesTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Most of the tests in this class run against every one of these caches.
 */
private Iterable<LoadingCache<Object, Object>> caches() {
  // lots of different ways to configure a LoadingCache
  CacheBuilderFactory factory = cacheFactory();
  return Iterables.transform(factory.buildAllPermutations(),
      new Function<Caffeine<Object, Object>, LoadingCache<Object, Object>>() {
        @Override public LoadingCache<Object, Object> apply(
            Caffeine<Object, Object> builder) {
          return CaffeinatedGuava.build(builder.recordStats(), identityLoader());
        }
      });
}