Class UniversalResiliencePolicy<K,​V>

  • All Implemented Interfaces:
    org.cache2k.Customization, org.cache2k.DataAware<K,​V>, org.cache2k.DataAwareCustomization<K,​V>, org.cache2k.expiry.ExpiryTimeValues, org.cache2k.io.ResiliencePolicy<K,​V>

    public class UniversalResiliencePolicy<K,​V>
    extends Object
    implements org.cache2k.io.ResiliencePolicy<K,​V>
    Resilience policy which implements an exponential back off of the retry intervals.
    Author:
    Jens Wilke
    See Also:
    cache2k user guide - Exceptions and Resilience
    • Constructor Detail

      • UniversalResiliencePolicy

        public UniversalResiliencePolicy​(long resilienceDuration,
                                         long retryInterval)
        Construct universal resilience policy. Duration and interval values are in milliseconds.
        Parameters:
        resilienceDuration - maximum duration in which exceptions are suppressed if a previous load was successful
        retryInterval - start value of retry interval
      • UniversalResiliencePolicy

        public UniversalResiliencePolicy​(long resilienceDuration,
                                         long maxRetryInterval,
                                         long retryInterval,
                                         double multiplier)
        Construct universal resilience policy. Duration and interval values are in milliseconds.
        Parameters:
        resilienceDuration - maximum duration in which exceptions are suppressed if a previous load was successful
        maxRetryInterval - maximum value for retryInterval
        retryInterval - start value of retry interval
        multiplier - multiplier for retry interval in case of consecutive load exceptions
    • Method Detail

      • suppressExceptionUntil

        public long suppressExceptionUntil​(K key,
                                           org.cache2k.io.LoadExceptionInfo<K,​V> loadExceptionInfo,
                                           org.cache2k.CacheEntry<K,​V> cachedEntry)
        Allows exceptions to be suppressed for a maximum of resilienceDuration starting from last successful load. Returns a shorter time based on the retry configuration with exponential backoff.
        Specified by:
        suppressExceptionUntil in interface org.cache2k.io.ResiliencePolicy<K,​V>
      • retryLoadAfter

        public long retryLoadAfter​(K key,
                                   org.cache2k.io.LoadExceptionInfo<K,​V> loadExceptionInfo)
        Retries after the load time based on the retry configuration with exponential backoff.
        Specified by:
        retryLoadAfter in interface org.cache2k.io.ResiliencePolicy<K,​V>
      • getMultiplier

        public double getMultiplier()
      • getResilienceDuration

        public long getResilienceDuration()
      • getMaxRetryInterval

        public long getMaxRetryInterval()
      • getRetryInterval

        public long getRetryInterval()