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

Class CacheBuilder

output/java_guava/1.4.13/CacheBuilder.java:146–914  ·  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

144
145
146@GwtCompatible(emulated = true)
147public final class CacheBuilder<K, V> {
148 private static final int DEFAULT_INITIAL_CAPACITY = 16;
149 private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
150 private static final int DEFAULT_EXPIRATION_NANOS = 0;
151 private static final int DEFAULT_REFRESH_NANOS = 0;
152
153
154 static final Supplier<? extends StatsCounter> NULL_STATS_COUNTER = Suppliers.ofInstance(new StatsCounter() {
155 @Override
156 public void recordHits(int count) {}
157
158 @Override
159 public void recordMisses(int count) {}
160
161 @Override
162 public void recordLoadSuccess(long loadTime) {}
163
164 @Override
165 public void recordLoadException(long loadTime) {}
166
167 @Override
168 public void recordEviction() {}
169
170 @Override
171 public CacheStats snapshot() {
172 return EMPTY_STATS;
173 }
174 });
175
176
177 static final CacheStats EMPTY_STATS = new CacheStats(0, 0, 0, 0, 0, 0);
178
179
180 static final Supplier<StatsCounter> CACHE_STATS_COUNTER = 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 = new Ticker() {

Callers

nothing calls this directly

Calls 2

ofInstanceMethod · 0.95
getNameMethod · 0.45

Tested by

no test coverage detected