K
- The key typeV
- The value typepublic static final class ExpiringMap.Builder<K,V> extends Object
ExpiringMap
. Defaults to using
ExpiringMap.ExpirationPolicy.ACCESSED
and an expiration time of 5
TimeUnit.MINUTES
Modifier and Type | Method and Description |
---|---|
<K1 extends K,V1 extends V> |
build()
Builds and returns an expiring map.
|
<K1 extends K,V1 extends V> |
entryLoader(Function<? super K1,? super V1> loader)
Sets the
Function that is called when an entry is expired
and should be re-initialized |
ExpiringMap.Builder<K,V> |
expiration(long duration,
TimeUnit timeUnit)
Sets the default map entry expiration.
|
ExpiringMap.Builder<K,V> |
expirationPolicy(ExpiringMap.ExpirationPolicy expirationPolicy)
Sets the map entry expiration policy.
|
<K1 extends K,V1 extends V> |
onExpiry(BiConsumer<? super K1,? super V1> expired)
Sets the
BiConsumer to apply to expired entries |
ExpiringMap.Builder<K,V> |
variableExpiration()
Allows for map entries to have individual expirations and for
expirations to be changed.
|
public <K1 extends K,V1 extends V> ExpiringMap<K1,V1> build()
K1
- The key typeV1
- The value typeExpiringMap
objectpublic ExpiringMap.Builder<K,V> expiration(long duration, TimeUnit timeUnit)
duration
- the length of time after an entry is created that it
should be removedtimeUnit
- the unit that duration
is expressed inpublic <K1 extends K,V1 extends V> ExpiringMap.Builder<K1,V1> entryLoader(Function<? super K1,? super V1> loader)
Function
that is called when an entry is expired
and should be re-initializedK1
- The type of the keys to deal withV1
- The type of the values to deal withloader
- to setpublic <K1 extends K,V1 extends V> ExpiringMap.Builder<K1,V1> onExpiry(BiConsumer<? super K1,? super V1> expired)
BiConsumer
to apply to expired entriesK1
- The type of the keys to deal withV1
- The type of the values to deal withexpired
- A BiConsumer
that is applied to entries upon
expirationpublic ExpiringMap.Builder<K,V> expirationPolicy(ExpiringMap.ExpirationPolicy expirationPolicy)
expirationPolicy
- The ExpiringMap.ExpirationPolicy
to setpublic ExpiringMap.Builder<K,V> variableExpiration()
Copyright © 2015. All rights reserved.