com.github.benmanes.caffeine.cache.Caffeine.requireNonLoadingCache()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(224)

本文整理了Java中com.github.benmanes.caffeine.cache.Caffeine.requireNonLoadingCache()方法的一些代码示例,展示了Caffeine.requireNonLoadingCache()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Caffeine.requireNonLoadingCache()方法的具体详情如下:
包路径:com.github.benmanes.caffeine.cache.Caffeine
类名称:Caffeine
方法名:requireNonLoadingCache

Caffeine.requireNonLoadingCache介绍

暂无

代码示例

代码示例来源:origin: ben-manes/caffeine

/**
 * Builds a cache which does not automatically load values when keys are requested unless a
 * mapping function is provided. Note that multiple threads can concurrently load values for
 * distinct keys.
 * <p>
 * Consider {@link #build(CacheLoader)} instead, if it is feasible to implement a
 * {@code CacheLoader}.
 * <p>
 * This method does not alter the state of this {@code Caffeine} instance, so it can be invoked
 * again to create multiple independent caches.
 *
 * @param <K1> the key type of the cache
 * @param <V1> the value type of the cache
 * @return a cache having the requested features
 */
@NonNull
public <K1 extends K, V1 extends V> Cache<K1, V1> build() {
 requireWeightWithWeigher();
 requireNonLoadingCache();
 @SuppressWarnings("unchecked")
 Caffeine<K1, V1> self = (Caffeine<K1, V1>) this;
 return isBounded()
   ? new BoundedLocalCache.BoundedLocalManualCache<>(self)
   : new UnboundedLocalCache.UnboundedLocalManualCache<>(self);
}

代码示例来源:origin: ben-manes/caffeine

requireState(writer == null, "CacheWriter can not be combined with AsyncCache");
requireWeightWithWeigher();
requireNonLoadingCache();

代码示例来源:origin: com.github.ben-manes.caffeine/caffeine

/**
 * Builds a cache which does not automatically load values when keys are requested.
 * <p>
 * Consider {@link #build(CacheLoader)} instead, if it is feasible to implement a
 * {@code CacheLoader}.
 * <p>
 * This method does not alter the state of this {@code Caffeine} instance, so it can be invoked
 * again to create multiple independent caches.
 *
 * @param <K1> the key type of the cache
 * @param <V1> the value type of the cache
 * @return a cache having the requested features
 */
@Nonnull
public <K1 extends K, V1 extends V> Cache<K1, V1> build() {
 requireWeightWithWeigher();
 requireNonLoadingCache();
 @SuppressWarnings("unchecked")
 Caffeine<K1, V1> self = (Caffeine<K1, V1>) this;
 return isBounded() || refreshes()
   ? new BoundedLocalCache.BoundedLocalManualCache<>(self)
   : new UnboundedLocalCache.UnboundedLocalManualCache<>(self);
}

相关文章