org.omnaest.utils.structure.element.cached
Class CachedElementTimed<T>
java.lang.Object
org.omnaest.utils.structure.element.cached.CachedElement<T>
org.omnaest.utils.structure.element.cached.CachedElementTimed<T>
- Type Parameters:
T -
public class CachedElementTimed<T>
- extends CachedElement<T>
Extension of the CachedElement which allows declare a duration after passing that the cache becomes dirty and is not be
used anymore.
The intension of use are situation in which references can be ensured to be actual for a given period of time. But after
passing this period the cache should not be used anymore and a new element reference resolved again.
Note: if the cached element gets a new value set to, the internal duration timer will be reseted and starts to count beginning
from zero again.
If the given duration of validity is exceeded the internal reference of the actually cached element gets removed. This allows
the garbage collector to take action. But be aware that this mechanism needs active invocation to the
CachedElement.hasValueResolved() or CachedElement.getValueFromCacheOnly() or CachedElement.getValue() method.
- Author:
- Omnaest
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
validCacheDurationInMilliseconds
protected Long validCacheDurationInMilliseconds
CachedElementTimed
public CachedElementTimed(CachedElement.ValueResolver<T> valueResolver,
Long validCacheDurationInMilliseconds)
- Parameters:
valueResolver - validCacheDurationInMilliseconds - - See Also:
CachedElementTimed
newCachedValue
protected CachedElement.CachedValue<T> newCachedValue()
- Description copied from class:
CachedElement
- Creates a new
CachedElement.CachedValue instance. Override this to alternate the behavior of the CachedElement
- Overrides:
newCachedValue in class CachedElement<T>
- Returns:
getValidCacheDurationInMilliseconds
public Long getValidCacheDurationInMilliseconds()
setValidCacheDurationInMilliseconds
public void setValidCacheDurationInMilliseconds(Long validCacheDurationInMilliseconds)
Copyright © 2013. All Rights Reserved.