Class Timing<K,​V>

    • Constructor Detail

      • Timing

        public Timing()
    • Method Detail

      • setTarget

        public void setTarget​(TimerEventListener<K,​V> c)
        Set the target for timer events. Called during cache build before any timer tasks are created. For each cache instance there is a timing instance and both reference each other. We create timing first, then the cache.
      • cancelAll

        public void cancelAll()
        Cancels all pending timer events.
      • calculateNextRefreshTime

        public abstract long calculateNextRefreshTime​(Entry<K,​V> e,
                                                      V value,
                                                      long loadTime)
        Calculates the expiry time for a value that was just loaded or inserted into the cache.
        Parameters:
        e - The entry, filled with the previous value if there is a value present already.
        v - The new value or an exception wrapped in ExceptionWrapper
        loadTime - the time immediately before the load started
        Returns:
        Point in time when the entry should expire. Meaning identical to ExpiryPolicy.calculateExpiryTime(Object, Object, long, CacheEntry)
      • suppressExceptionUntil

        public abstract long suppressExceptionUntil​(Entry<K,​V> e,
                                                    org.cache2k.io.LoadExceptionInfo inf)
        Delegated to the resilience policy
        See Also:
        ResiliencePolicy.suppressExceptionUntil(K, org.cache2k.io.LoadExceptionInfo<K, V>, org.cache2k.CacheEntry<K, V>)
      • cacheExceptionUntil

        public abstract long cacheExceptionUntil​(Entry<K,​V> e,
                                                 org.cache2k.io.LoadExceptionInfo inf)
        Delegated to the resilience policy
        See Also:
        ResiliencePolicy.retryLoadAfter(K, org.cache2k.io.LoadExceptionInfo<K, V>)
      • stopStartTimer

        public long stopStartTimer​(long expiryTime,
                                   Entry<K,​V> e)
        Convert expiry value to the entry field value, essentially maps 0 to Entry.EXPIRED since 0 is a virgin entry. Restart the timer if needed.
        Parameters:
        expiryTime - calculated expiry time
        Returns:
        sanitized nextRefreshTime for storage in the entry.
      • startRefreshProbationTimer

        public boolean startRefreshProbationTimer​(Entry<K,​V> e,
                                                  long nextRefreshTime)
        Start probation timer.
      • cancelExpiryTimer

        public void cancelExpiryTimer​(Entry<K,​V> e)
        Cancel the timer on the entry, if a timer was set.
      • scheduleFinalTimerForSharpExpiry

        public void scheduleFinalTimerForSharpExpiry​(Entry<K,​V> e)
        Schedule second timer event for the expiry tie if sharp expiry is switched on.