MCPcopy
hub / github.com/google/guava / get

Method get

guava/src/com/google/common/cache/LocalCache.java:2047–2083  ·  view source on GitHub ↗
(K key, int hash, CacheLoader<? super K, V> loader)

Source from the content-addressed store, hash-verified

2045 // loading
2046
2047 @CanIgnoreReturnValue
2048 V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
2049 checkNotNull(key);
2050 checkNotNull(loader);
2051 try {
2052 if (count != 0) { // read-volatile
2053 // don't call getLiveEntry, which would ignore loading values
2054 ReferenceEntry<K, V> e = getEntry(key, hash);
2055 if (e != null) {
2056 long now = map.ticker.read();
2057 V value = getLiveValue(e, now);
2058 if (value != null) {
2059 recordRead(e, now);
2060 statsCounter.recordHits(1);
2061 return scheduleRefresh(e, key, hash, value, now, loader);
2062 }
2063 ValueReference<K, V> valueReference = e.getValueReference();
2064 if (valueReference.isLoading()) {
2065 return waitForLoadingValue(e, key, valueReference);
2066 }
2067 }
2068 }
2069
2070 // at this point e is either null or expired;
2071 return lockedGetOrLoad(key, hash, loader);
2072 } catch (ExecutionException ee) {
2073 Throwable cause = ee.getCause();
2074 if (cause instanceof Error) {
2075 throw new ExecutionError((Error) cause);
2076 } else if (cause instanceof RuntimeException) {
2077 throw new UncheckedExecutionException(cause);
2078 }
2079 throw ee;
2080 } finally {
2081 postReadCleanup();
2082 }
2083 }
2084
2085 @Nullable V get(Object key, int hash) {
2086 try {

Callers

nothing calls this directly

Calls 15

getEntryMethod · 0.95
getLiveValueMethod · 0.95
recordReadMethod · 0.95
scheduleRefreshMethod · 0.95
waitForLoadingValueMethod · 0.95
lockedGetOrLoadMethod · 0.95
postReadCleanupMethod · 0.95
getLiveEntryMethod · 0.95
recordHitsMethod · 0.65
getValueReferenceMethod · 0.65
isLoadingMethod · 0.65

Tested by

no test coverage detected