public class MaximumAgeExpiryStrategy extends Object implements ExpiryStrategy
ExpiryStrategy
which expires all entries from the cache which are older than the
configured maximum age. This strategy should only be used in combination with other strategies
because there is no guarantee that it will delete any entry in a full cache.ExpiryStrategy.ExpiryPressure
Constructor and Description |
---|
MaximumAgeExpiryStrategy(int maxAge,
TimeUnit units)
Creates a new
MaximumAgeExpiryStrategy with the given maximum age in the given
TimeUnits. |
Modifier and Type | Method and Description |
---|---|
void |
performExpiry(CacheIteratorFactory iteratorFactory,
TrackableCache cache,
boolean hasLRUOrdering,
ExpiryStrategy.ExpiryPressure expiryPressure)
Initiates an expiry call to the cache and returns how many objects have been expired.
|
public MaximumAgeExpiryStrategy(int maxAge, TimeUnit units)
MaximumAgeExpiryStrategy
with the given maximum age in the given
TimeUnits.maxAge
- the maximum age of the cache entries in the given TimeUnit
. This value
has to be greater than 0units
- the TimeUnit for the maxAge. The value must not be nullpublic void performExpiry(CacheIteratorFactory iteratorFactory, TrackableCache cache, boolean hasLRUOrdering, ExpiryStrategy.ExpiryPressure expiryPressure)
ExpiryStrategy
ExpiryStrategy.ExpiryPressure
indicating how urgent it is.
The expiry of cache entries shall be triggered by calling Iterator.remove()
on the Iterator
provided by CacheIteratorFactory.create()
. Iterator
s created using that method, will allow cache
modifications during iteration.
Attention: This is not thread safe! Locking has to happen in the cache's implementation!
performExpiry
in interface ExpiryStrategy
iteratorFactory
- A CacheIteratorFactory
that creates an Iterator
to the caches
entries. The Iterator
created using the CacheIteratorFactory
shall be used
to removed entries from the cache.cache
- the TrackableCache
the ExpiryStrategy
is assigned tohasLRUOrdering
- If this is true, the collection has an LRU ordering, implying that it
will iterate from the oldest to the newest entry.expiryPressure
- Indicates if the expiry call is urgent or not.Copyright © 2024 levigo holding gmbh. All rights reserved.