Class ForgetfulMap.ValueCacheImpl<K,V>
java.lang.Object
org.ojalgo.type.ForgetfulMap.ValueCacheImpl<K,V>
- All Implemented Interfaces:
ForgetfulMap.ValueCache<V>
- Enclosing class:
ForgetfulMap<K,V>
private static final class ForgetfulMap.ValueCacheImpl<K,V>
extends Object
implements ForgetfulMap.ValueCache<V>
A re-implementation of
TypeCache backed by a ForgetfulMap. Essentially it's a supplier
that most of the time returns a cached value, and only recomputes it periodically.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionValueCacheImpl(K key, ForgetfulMap<K, V> cache, Function<? super K, ? extends V> valueSupplier) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidfinal Vfinal booleanIs there currently a value cached for this key?final booleanisDirty()final voidWill force re-creation of the value the next timegetCachedObject()is called.
-
Field Details
-
myCache
-
myDirty
private volatile boolean myDirty -
myKey
-
myValueSupplier
-
-
Constructor Details
-
ValueCacheImpl
-
-
Method Details
-
flushCache
public final void flushCache()- Specified by:
flushCachein interfaceForgetfulMap.ValueCache<K>
-
getCachedObject
- Specified by:
getCachedObjectin interfaceForgetfulMap.ValueCache<K>
-
isCacheSet
public final boolean isCacheSet()Is there currently a value cached for this key?- Specified by:
isCacheSetin interfaceForgetfulMap.ValueCache<K>
-
isDirty
public final boolean isDirty()- Specified by:
isDirtyin interfaceForgetfulMap.ValueCache<K>- 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.- Specified by:
makeDirtyin interfaceForgetfulMap.ValueCache<K>
-