Package org.cache2k.core.timing
Class StaticTiming<K,V>
- java.lang.Object
-
- org.cache2k.core.timing.Timing<K,V>
-
- org.cache2k.core.timing.StaticTiming<K,V>
-
- All Implemented Interfaces:
NeedsClose
public class StaticTiming<K,V> extends Timing<K,V>
Expiry time is constant- Author:
- Jens Wilke
-
-
Field Summary
Fields Modifier and Type Field Description protected org.cache2k.operation.TimeReferenceclockprotected longexpiryMillisprotected longlagMillisprotected booleanrefreshAheadprotected org.cache2k.io.ResiliencePolicy<K,V>resiliencePolicyprotected booleansharpExpiry
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcacheExceptionUntil(Entry<K,V> e, org.cache2k.io.LoadExceptionInfo inf)Delegated to the resilience policylongcalculateNextRefreshTime(Entry<K,V> e, V value, long loadTime)Calculates the expiry time for a value that was just loaded or inserted into the cache.voidcancelAll()Cancels all pending timer events.voidcancelExpiryTimer(Entry<K,V> e)Cancel the timer on the entry, if a timer was set.voidclose(InternalCacheCloseContext closeContext)voidscheduleFinalTimerForSharpExpiry(Entry<K,V> e)Schedule second timer event for the expiry tie if sharp expiry is switched on.voidsetTarget(TimerEventListener<K,V> target)Set the target for timer events.booleanstartRefreshProbationTimer(Entry<K,V> e, long nextRefreshTime)Start probation timer.longstopStartTimer(long expiryTime, Entry<K,V> e)Calculate the needed timer value, which depends on the setting of sharpExpiry and refreshAhead.longsuppressExceptionUntil(Entry<K,V> e, org.cache2k.io.LoadExceptionInfo inf)Delegated to the resilience policy
-
-
-
Method Detail
-
setTarget
public void setTarget(TimerEventListener<K,V> target)
Description copied from class:TimingSet 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()
Description copied from class:TimingCancels all pending timer events.
-
close
public void close(InternalCacheCloseContext closeContext)
-
calculateNextRefreshTime
public long calculateNextRefreshTime(Entry<K,V> e, V value, long loadTime)
Description copied from class:TimingCalculates the expiry time for a value that was just loaded or inserted into the cache.- Specified by:
calculateNextRefreshTimein classTiming<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:TimingDelegated to the resilience policy- Specified by:
suppressExceptionUntilin classTiming<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:TimingDelegated to the resilience policy- Specified by:
cacheExceptionUntilin classTiming<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 caseEntry.EXPIREDis returned. Callers need to check that and may be remove the entry consequently from the cache.- Overrides:
stopStartTimerin classTiming<K,V>- Parameters:
expiryTime- expiry time with special values as defined inExpiryTimeValuese- the entry- Returns:
- adjusted value for nextRefreshTime.
-
startRefreshProbationTimer
public boolean startRefreshProbationTimer(Entry<K,V> e, long nextRefreshTime)
Description copied from class:TimingStart probation timer.- Overrides:
startRefreshProbationTimerin classTiming<K,V>- Returns:
- true, if entry is finally expired.
-
scheduleFinalTimerForSharpExpiry
public void scheduleFinalTimerForSharpExpiry(Entry<K,V> e)
Description copied from class:TimingSchedule second timer event for the expiry tie if sharp expiry is switched on.- Overrides:
scheduleFinalTimerForSharpExpiryin classTiming<K,V>
-
-