use of org.springframework.cache.guava.GuavaCacheManager in project hono by eclipse.
the class AbstractAdapterConfig method newGuavaCache.
/**
* Create a new cache provider based on Guava and Spring Cache.
*
* @param config The configuration to use as base for this cache.
* @return A new cache provider or {@code null} if no cache should be used.
*/
private static final CacheProvider newGuavaCache(final RequestResponseClientConfigProperties config) {
final int minCacheSize = config.getResponseCacheMinSize();
final long maxCacheSize = config.getResponseCacheMaxSize();
if (maxCacheSize <= 0) {
return null;
}
final CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().concurrencyLevel(1).initialCapacity(minCacheSize).maximumSize(Math.max(minCacheSize, maxCacheSize));
final GuavaCacheManager manager = new GuavaCacheManager();
manager.setAllowNullValues(false);
manager.setCacheBuilder(builder);
return new SpringCacheProvider(manager);
}
Aggregations