- 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 java.lang.Object implements ForgetfulMap.ValueCache<V>
A re-implementation ofTypeCachebacked 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>myCacheprivate booleanmyDirtyprivate KmyKeyprivate java.util.function.Function<? super K,? extends V>myValueSupplier
-
Constructor Summary
Constructors Constructor Description ValueCacheImpl(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 voidflushCache()VgetCachedObject()booleanisCacheSet()Is there currently a value cached for this key?booleanisDirty()voidmakeDirty()Will force re-creation of the value the next timegetCachedObject()is called.
-
-
-
Method Detail
-
flushCache
public final void flushCache()
- Specified by:
flushCachein interfaceForgetfulMap.ValueCache<K>
-
getCachedObject
public final V 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>
-
-