Package org.ojalgo.type
Class ForgetfulMap.ValueCache<K,V>
- java.lang.Object
-
- org.ojalgo.type.ForgetfulMap.ValueCache<K,V>
-
- Enclosing class:
- ForgetfulMap<K,V>
public static final class ForgetfulMap.ValueCache<K,V> extends java.lang.Object
A re-implementation ofTypeCache
backed by aForgetfulMap
. Essentially it's a supplier that most of the time returns a cached value, and only recomputes it periodically.
-
-
Field Summary
Fields Modifier and Type Field Description private ForgetfulMap<K,V>
myCache
private boolean
myDirty
private K
myKey
private java.util.function.Function<? super K,? extends V>
myValueSupplier
-
Constructor Summary
Constructors Constructor Description ValueCache(K key, ForgetfulMap<K,V> cache, java.util.function.Function<? super K,? extends V> valueSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flushCache()
V
getCachedObject()
boolean
isCacheSet()
Is there currently a value cached for this key?boolean
isDirty()
void
makeDirty()
Will force re-creation of the value the next timegetCachedObject()
is called.
-
-
-
Method Detail
-
flushCache
public final void flushCache()
-
getCachedObject
public final V getCachedObject()
-
isCacheSet
public final boolean isCacheSet()
Is there currently a value cached for this key?
-
isDirty
public final boolean isDirty()
- Returns:
- true if
makeDirty()
has been called since the last timegetCachedObject()
was called.
-
makeDirty
public final void makeDirty()
Will force re-creation of the value the next timegetCachedObject()
is called. This method does NOT immediately remove or invalidate the value from the underlying cache.
-
-