static class LocalCache.LoadingValueReference<K,V> extends java.lang.Object implements LocalCache.ValueReference<K,V>
| Modifier and Type | Field and Description |
|---|---|
(package private) SettableFuture<V> |
futureValue |
(package private) LocalCache.ValueReference<K,V> |
oldValue |
(package private) Stopwatch |
stopwatch |
| Constructor and Description |
|---|
LoadingValueReference() |
LoadingValueReference(LocalCache.ValueReference<K,V> oldValue) |
| Modifier and Type | Method and Description |
|---|---|
V |
compute(K key,
java.util.function.BiFunction<? super K,? super V,? extends V> function) |
LocalCache.ValueReference<K,V> |
copyFor(java.lang.ref.ReferenceQueue<V> queue,
V value,
ReferenceEntry<K,V> entry)
Creates a copy of this reference for the given entry.
|
long |
elapsedNanos() |
private ListenableFuture<V> |
fullyFailedFuture(java.lang.Throwable t) |
V |
get()
Returns the value.
|
ReferenceEntry<K,V> |
getEntry()
Returns the entry associated with this value reference, or
null if this value
reference is independent of any entry. |
LocalCache.ValueReference<K,V> |
getOldValue() |
int |
getWeight()
Returns the weight of this entry.
|
boolean |
isActive()
Returns true if this reference contains an active value, meaning one that is still considered
present in the cache.
|
boolean |
isLoading()
Returns true if a new value is currently loading, regardless of whether or not there is an
existing value.
|
ListenableFuture<V> |
loadFuture(K key,
CacheLoader<? super K,V> loader) |
void |
notifyNewValue(V newValue)
Notify pending loads that a new value was set.
|
boolean |
set(V newValue) |
boolean |
setException(java.lang.Throwable t) |
V |
waitForValue()
Waits for a value that may still be loading.
|
volatile LocalCache.ValueReference<K,V> oldValue
final SettableFuture<V> futureValue
final Stopwatch stopwatch
public LoadingValueReference()
public LoadingValueReference(LocalCache.ValueReference<K,V> oldValue)
public boolean isLoading()
LocalCache.ValueReferenceisLoading in interface LocalCache.ValueReference<K,V>public boolean isActive()
LocalCache.ValueReferenceisActive in interface LocalCache.ValueReference<K,V>public int getWeight()
LocalCache.ValueReferencegetWeight in interface LocalCache.ValueReference<K,V>public boolean set(V newValue)
public boolean setException(java.lang.Throwable t)
private ListenableFuture<V> fullyFailedFuture(java.lang.Throwable t)
public void notifyNewValue(V newValue)
LocalCache.ValueReferencenotifyNewValue in interface LocalCache.ValueReference<K,V>public ListenableFuture<V> loadFuture(K key, CacheLoader<? super K,V> loader)
public V compute(K key, java.util.function.BiFunction<? super K,? super V,? extends V> function)
public long elapsedNanos()
public V waitForValue() throws java.util.concurrent.ExecutionException
LocalCache.ValueReferencewaitForValue in interface LocalCache.ValueReference<K,V>java.util.concurrent.ExecutionException - if the loading thread throws an exceptionpublic V get()
LocalCache.ValueReferenceget in interface LocalCache.ValueReference<K,V>public LocalCache.ValueReference<K,V> getOldValue()
public ReferenceEntry<K,V> getEntry()
LocalCache.ValueReferencenull if this value
reference is independent of any entry.getEntry in interface LocalCache.ValueReference<K,V>public LocalCache.ValueReference<K,V> copyFor(java.lang.ref.ReferenceQueue<V> queue, V value, ReferenceEntry<K,V> entry)
LocalCache.ValueReferencevalue may be null only for a loading reference.
copyFor in interface LocalCache.ValueReference<K,V>