public class ExpiryUtils
extends java.lang.Object
Constructor and Description |
---|
ExpiryUtils() |
Modifier and Type | Method and Description |
---|---|
static <K,V> Expiry<K,V> |
convertToExpiry(ExpiryPolicy<K,V> expiryPolicy) |
static <K,V> ExpiryPolicy<K,V> |
convertToExpiryPolicy(Expiry<K,V> expiry) |
static long |
getExpirationMillis(long now,
java.time.Duration duration) |
static <K,V> java.time.Duration |
getExpiryForCreation(K key,
V value,
ExpiryPolicy<? super K,? super V> expiry)
Returns the expiry for creation duration returned by the provided
ExpiryPolicy but checks for immediate
expiry, null expiry and exceptions. |
static boolean |
isExpiryDurationInfinite(java.time.Duration duration) |
static java.time.temporal.TemporalUnit |
jucTimeUnitToTemporalUnit(java.util.concurrent.TimeUnit timeUnit) |
public static boolean isExpiryDurationInfinite(java.time.Duration duration)
public static <K,V> Expiry<K,V> convertToExpiry(ExpiryPolicy<K,V> expiryPolicy)
public static <K,V> ExpiryPolicy<K,V> convertToExpiryPolicy(Expiry<K,V> expiry)
public static java.time.temporal.TemporalUnit jucTimeUnitToTemporalUnit(java.util.concurrent.TimeUnit timeUnit)
public static long getExpirationMillis(long now, java.time.Duration duration)
public static <K,V> java.time.Duration getExpiryForCreation(K key, V value, ExpiryPolicy<? super K,? super V> expiry)
ExpiryPolicy
but checks for immediate
expiry, null expiry and exceptions. In all those cases, null
will be returned.K
- type of keyV
- type of valuekey
- key to pass to ExpiryPolicy.getExpiryForCreation(Object, Object)
value
- value to pass to to pass to ExpiryPolicy.getExpiryForCreation(Object, Object)
expiry
- expiry queriedExpiryPolicy.getExpiryForCreation(Object, Object)
, null
if the call throws an exception, if the returned duration is null
or if it is lower or equal to 0