MCPcopy Create free account
hub / github.com/antlr/codebuff / CacheBuilder

Class CacheBuilder

corpus/java/training/guava/cache/CacheBuilder.java:147–895  ·  view source on GitHub ↗

A builder of LoadingCache and Cache instances having any combination of the following features: automatic loading of entries into the cache least-recently-used eviction when a maximum size is exceeded time-based expiration of entries, measured since last access o

Source from the content-addressed store, hash-verified

145 * @since 10.0
146 */
147@GwtCompatible(emulated = true)
148public final class CacheBuilder<K, V> {
149 private static final int DEFAULT_INITIAL_CAPACITY = 16;
150 private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
151 private static final int DEFAULT_EXPIRATION_NANOS = 0;
152 private static final int DEFAULT_REFRESH_NANOS = 0;
153
154 static final Supplier<? extends StatsCounter> NULL_STATS_COUNTER =
155 Suppliers.ofInstance(
156 new StatsCounter() {
157 @Override
158 public void recordHits(int count) {}
159
160 @Override
161 public void recordMisses(int count) {}
162
163 @Override
164 public void recordLoadSuccess(long loadTime) {}
165
166 @Override
167 public void recordLoadException(long loadTime) {}
168
169 @Override
170 public void recordEviction() {}
171
172 @Override
173 public CacheStats snapshot() {
174 return EMPTY_STATS;
175 }
176 });
177 static final CacheStats EMPTY_STATS = new CacheStats(0, 0, 0, 0, 0, 0);
178
179 static final Supplier<StatsCounter> CACHE_STATS_COUNTER =
180 new Supplier<StatsCounter>() {
181 @Override
182 public StatsCounter get() {
183 return new SimpleStatsCounter();
184 }
185 };
186
187 enum NullListener implements RemovalListener<Object, Object> {
188 INSTANCE;
189
190 @Override
191 public void onRemoval(RemovalNotification<Object, Object> notification) {}
192 }
193
194 enum OneWeigher implements Weigher<Object, Object> {
195 INSTANCE;
196
197 @Override
198 public int weigh(Object key, Object value) {
199 return 1;
200 }
201 }
202
203 static final Ticker NULL_TICKER =
204 new Ticker() {

Callers

nothing calls this directly

Calls 2

ofInstanceMethod · 0.95
getNameMethod · 0.45

Tested by

no test coverage detected