Class ForgetfulMap.ValueCache<K,​V>

  • Enclosing class:
    ForgetfulMap<K,​V>

    public static final class ForgetfulMap.ValueCache<K,​V>
    extends java.lang.Object
    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 Detail

      • myDirty

        private volatile boolean myDirty
      • myKey

        private final K myKey
      • myValueSupplier

        private final java.util.function.Function<? super K,​? extends V> myValueSupplier
    • Constructor Detail

      • ValueCache

        ValueCache​(K key,
                   ForgetfulMap<K,​V> cache,
                   java.util.function.Function<? super K,​? extends V> valueSupplier)
    • 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?
      • makeDirty

        public final void makeDirty()
        Will force re-creation of the value the next time getCachedObject() is called. This method does NOT immediately remove or invalidate the value from the underlying cache.