Interface ResiliencePolicy<K,​V>

    • Field Detail

      • DISABLED_POLICY

        static final ResiliencePolicy<?,​?> DISABLED_POLICY
        A policy always returning zero, thus disabling resilience features. This is also used as default when no resilience policy is set.
    • Method Detail

      • disable

        static <K,​V> void disable​(Cache2kBuilder<K,​V> b)
      • suppressExceptionUntil

        long suppressExceptionUntil​(K key,
                                    LoadExceptionInfo<K,​V> loadExceptionInfo,
                                    CacheEntry<K,​V> cachedEntry)
        Called after the loader threw an exception and a previous value is available. Returns a point in time determining how long the exceptions should be suppressed, or in other words, until when the previous loaded value should be returned by the cache.

        The returned value is a point in time. If the currently cached content is expired, returning a future time will effectively extend the entry expiry.

        If Cache2kBuilder.expireAfterWrite(long, TimeUnit) is specified, the maximum duration will be capped with the specified value.

        Returning 0 or a time in the past means the exception should not be suppressed. The cache will call immediately retryLoadAfter(K, org.cache2k.io.LoadExceptionInfo<K, V>) to determine how long the exception should stay in the cache and when the next retry attempt takes place.

        If the exception is not suppressed, it will be wrapped into a CacheLoaderException and propagated to the cache client. This is customizable by the ExceptionPropagator.

        Parameters:
        cachedEntry - The entry representing the currently cached content. It is possible that this data is already expired. This entry never contains an exception.
        Returns:
        Time in the future when the content should expire again. A zero or a time before the current time means the exception will not be suppressed. A ExpiryTimeValues.ETERNAL means the exception will be suppressed and the recent content will be returned eternally. If the returned time is after LoadExceptionInfo.getLoadTime() the exception will be suppressed for the ongoing operation.