Package com.google.common.cache
Class LocalCache.StrongValueReference<K,V>
java.lang.Object
com.google.common.cache.LocalCache.StrongValueReference<K,V>
- All Implemented Interfaces:
LocalCache.ValueReference<K,V>
- Direct Known Subclasses:
LocalCache.WeightedStrongValueReference
- Enclosing class:
- LocalCache<K,
V>
static class LocalCache.StrongValueReference<K,V>
extends Object
implements LocalCache.ValueReference<K,V>
References a strong value.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopyFor(ReferenceQueue<V> queue, V value, ReferenceEntry<K, V> entry) Creates a copy of this reference for the given entry.get()Returns the value.getEntry()Returns the entry associated with this value reference, ornullif this value reference is independent of any entry.intReturns the weight of this entry.booleanisActive()Returns true if this reference contains an active value, meaning one that is still considered present in the cache.booleanReturns true if a new value is currently loading, regardless of whether there is an existing value.voidnotifyNewValue(V newValue) Notify pending loads that a new value was set.Waits for a value that may still be loading.
-
Field Details
-
referent
-
-
Constructor Details
-
StrongValueReference
StrongValueReference(V referent)
-
-
Method Details
-
get
Description copied from interface:LocalCache.ValueReferenceReturns the value. Does not block or throw exceptions.- Specified by:
getin interfaceLocalCache.ValueReference<K,V>
-
getWeight
public int getWeight()Description copied from interface:LocalCache.ValueReferenceReturns the weight of this entry. This is assumed to be static between calls to setValue.- Specified by:
getWeightin interfaceLocalCache.ValueReference<K,V>
-
getEntry
Description copied from interface:LocalCache.ValueReferenceReturns the entry associated with this value reference, ornullif this value reference is independent of any entry.- Specified by:
getEntryin interfaceLocalCache.ValueReference<K,V>
-
copyFor
public LocalCache.ValueReference<K,V> copyFor(ReferenceQueue<V> queue, V value, ReferenceEntry<K, V> entry) Description copied from interface:LocalCache.ValueReferenceCreates a copy of this reference for the given entry.valuemay be null only for a loading reference.- Specified by:
copyForin interfaceLocalCache.ValueReference<K,V>
-
isLoading
public boolean isLoading()Description copied from interface:LocalCache.ValueReferenceReturns true if a new value is currently loading, regardless of whether there is an existing value. It is assumed that the return value of this method is constant for any given ValueReference instance.- Specified by:
isLoadingin interfaceLocalCache.ValueReference<K,V>
-
isActive
public boolean isActive()Description copied from interface:LocalCache.ValueReferenceReturns true if this reference contains an active value, meaning one that is still considered present in the cache. Active values consist of live values, which are returned by cache lookups, and dead values, which have been evicted but awaiting removal. Non-active values consist strictly of loading values, though during refresh a value may be both active and loading.- Specified by:
isActivein interfaceLocalCache.ValueReference<K,V>
-
waitForValue
Description copied from interface:LocalCache.ValueReferenceWaits for a value that may still be loading. Unlike get(), this method can block (in the case of FutureValueReference).- Specified by:
waitForValuein interfaceLocalCache.ValueReference<K,V>
-
notifyNewValue
Description copied from interface:LocalCache.ValueReferenceNotify pending loads that a new value was set. This is only relevant to loading value references.- Specified by:
notifyNewValuein interfaceLocalCache.ValueReference<K,V>
-