Class CaffeineUtils


  • public final class CaffeineUtils
    extends Object
    Utility class for Caffeine-related workarounds.
    • Method Detail

      • invalidateEagerly

        public static <K,​V,​E extends ExceptionPromise<V,​E> invalidateEagerly​(com.github.benmanes.caffeine.cache.AsyncCache<K,​V> cache,
                                                                                                 Promise<V,​E> promise,
                                                                                                 K key)
        Preemptively invalidates the cache entry on failure.

        Let Caffeine handle the removal if the entry is already completed. This avoids a recursive modification issue from the underlying map implementation.

        Type Parameters:
        K - type of the key
        V - type of the cached value
        E - promise's exception type
        Parameters:
        cache - the async cache
        promise - promise of the cache entry
        key - the looked up key
        Returns:
        a new promise doing the eager cache invalidation (if it's not completed yet), otherwise the same promise.
        See Also:
        Caffeine issue 372