Exemplo n.º 1
0
 public <K, V> LoadingCache<K, V> build(CacheLoader<K, V> loader) {
   LoadingCache<K, V> cache = null;
   if (isCaffeine()) {
     cache = isAsync() ? caffeine.buildAsync(loader).synchronous() : caffeine.build(loader);
   } else {
     cache =
         new GuavaLoadingCache<>(
             guava.build(
                 com.google.common.cache.CacheLoader.asyncReloading(
                     new SingleLoader<>(loader), executor.delegate())),
             ticker(),
             isRecordingStats());
   }
   this.cache = cache;
   return cache;
 }
Exemplo n.º 2
0
 public <K, V> AsyncLoadingCache<K, V> buildAsync(AsyncCacheLoader<K, V> loader) {
   checkState(isCaffeine() && isAsync());
   AsyncLoadingCache<K, V> cache = caffeine.buildAsync(loader);
   this.cache = cache.synchronous();
   return cache;
 }