/** Determines if the cache should operate in read through mode. */ private boolean isReadThrough() { return config.isReadThrough() && (config.getCacheLoaderFactory() != null); }
/** Creates a cache that does not read through on a cache miss. */ private CacheProxy<K, V> newCacheProxy() { Optional<CacheLoader<K, V>> cacheLoader = Optional.ofNullable(config.getCacheLoaderFactory()).map(Factory::create); return new CacheProxy<>(cacheName, executor, cacheManager, config, caffeine.build(), dispatcher, cacheLoader, expiryPolicy, ticker, statistics); }
/** Creates a cache that reads through on a cache miss. */ private CacheProxy<K, V> newLoadingCacheProxy() { CacheLoader<K, V> cacheLoader = config.getCacheLoaderFactory().create(); JCacheLoaderAdapter<K, V> adapter = new JCacheLoaderAdapter<>( cacheLoader, dispatcher, expiryPolicy, ticker, statistics); CacheProxy<K, V> cache = new LoadingCacheProxy<>(cacheName, executor, cacheManager, config, caffeine.build(adapter), dispatcher, cacheLoader, expiryPolicy, ticker, statistics); adapter.setCache(cache); return cache; }
static void checkTestCache(CaffeineConfiguration<?, ?> config) { checkStoreByValue(config); checkListener(config); assertThat(config.getKeyType(), is(Object.class)); assertThat(config.getValueType(), is(Object.class)); assertThat(config.getCacheLoaderFactory().create(), instanceOf(TestCacheLoader.class)); assertThat(config.getCacheWriter(), instanceOf(TestCacheWriter.class)); assertThat(config.isStatisticsEnabled(), is(true)); assertThat(config.isManagementEnabled(), is(true)); checkSize(config); checkRefresh(config); checkLazyExpiration(config); checkEagerExpiration(config); }
/** Determines if the cache should operate in read through mode. */ private boolean isReadThrough() { return config.isReadThrough() && (config.getCacheLoaderFactory() != null); }
/** Creates a cache that does not read through on a cache miss. */ private CacheProxy<K, V> newCacheProxy() { Optional<CacheLoader<K, V>> cacheLoader = Optional.ofNullable(config.getCacheLoaderFactory()).map(Factory::create); return new CacheProxy<>(cacheName, executor, cacheManager, config, caffeine.build(), dispatcher, cacheLoader, expiryPolicy, ticker, statistics); }
/** Creates a cache that reads through on a cache miss. */ private CacheProxy<K, V> newLoadingCacheProxy() { CacheLoader<K, V> cacheLoader = config.getCacheLoaderFactory().create(); JCacheLoaderAdapter<K, V> adapter = new JCacheLoaderAdapter<>( cacheLoader, dispatcher, expiryPolicy, ticker, statistics); CacheProxy<K, V> cache = new LoadingCacheProxy<>(cacheName, executor, cacheManager, config, caffeine.build(adapter), dispatcher, cacheLoader, expiryPolicy, ticker, statistics); adapter.setCache(cache); return cache; }