Class StaticTiming<K,​V>

  • All Implemented Interfaces:
    NeedsClose

    public class StaticTiming<K,​V>
    extends Timing<K,​V>
    Expiry time is constant
    Author:
    Jens Wilke
    • Field Detail

      • resiliencePolicy

        protected final org.cache2k.io.ResiliencePolicy<K,​V> resiliencePolicy
      • clock

        protected final org.cache2k.operation.TimeReference clock
      • sharpExpiry

        protected final boolean sharpExpiry
      • refreshAhead

        protected final boolean refreshAhead
      • expiryMillis

        protected final long expiryMillis
      • lagMillis

        protected final long lagMillis
    • Method Detail

      • setTarget

        public void setTarget​(TimerEventListener<K,​V> target)
        Description copied from class: Timing
        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.
        Overrides:
        setTarget in class Timing<K,​V>
      • cancelAll

        public void cancelAll()
        Description copied from class: Timing
        Cancels all pending timer events.
        Overrides:
        cancelAll in class Timing<K,​V>
      • calculateNextRefreshTime

        public long calculateNextRefreshTime​(Entry<K,​V> e,
                                             V value,
                                             long loadTime)
        Description copied from class: Timing
        Calculates the expiry time for a value that was just loaded or inserted into the cache.
        Specified by:
        calculateNextRefreshTime in class Timing<K,​V>
        Parameters:
        e - The entry, filled with the previous value if there is a value present already.
        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 long suppressExceptionUntil​(Entry<K,​V> e,
                                           org.cache2k.io.LoadExceptionInfo inf)
        Description copied from class: Timing
        Delegated to the resilience policy
        Specified by:
        suppressExceptionUntil in class Timing<K,​V>
        See Also:
        ResiliencePolicy.suppressExceptionUntil(K, org.cache2k.io.LoadExceptionInfo<K, V>, org.cache2k.CacheEntry<K, V>)
      • cacheExceptionUntil

        public long cacheExceptionUntil​(Entry<K,​V> e,
                                        org.cache2k.io.LoadExceptionInfo inf)
        Description copied from class: Timing
        Delegated to the resilience policy
        Specified by:
        cacheExceptionUntil in class Timing<K,​V>
        See Also:
        ResiliencePolicy.retryLoadAfter(K, org.cache2k.io.LoadExceptionInfo<K, V>)
      • stopStartTimer

        public long stopStartTimer​(long expiryTime,
                                   Entry<K,​V> e)
        Calculate the needed timer value, which depends on the setting of sharpExpiry and refreshAhead. It may happen that the timer is not started, because the time is already passed. In this case Entry.EXPIRED is returned. Callers need to check that and may be remove the entry consequently from the cache.
        Overrides:
        stopStartTimer in class Timing<K,​V>
        Parameters:
        expiryTime - expiry time with special values as defined in ExpiryTimeValues
        e - the entry
        Returns:
        adjusted value for nextRefreshTime.
      • startRefreshProbationTimer

        public boolean startRefreshProbationTimer​(Entry<K,​V> e,
                                                  long nextRefreshTime)
        Description copied from class: Timing
        Start probation timer.
        Overrides:
        startRefreshProbationTimer in class Timing<K,​V>
        Returns:
        true, if entry is finally expired.
      • scheduleFinalTimerForSharpExpiry

        public void scheduleFinalTimerForSharpExpiry​(Entry<K,​V> e)
        Description copied from class: Timing
        Schedule second timer event for the expiry tie if sharp expiry is switched on.
        Overrides:
        scheduleFinalTimerForSharpExpiry in class Timing<K,​V>
      • cancelExpiryTimer

        public void cancelExpiryTimer​(Entry<K,​V> e)
        Description copied from class: Timing
        Cancel the timer on the entry, if a timer was set.
        Overrides:
        cancelExpiryTimer in class Timing<K,​V>