类 ExpiringMap.Builder<K,V>
java.lang.Object
com.sh.util.concurrent.expiringmap.ExpiringMap.Builder<K,V>
- 封闭类:
- ExpiringMap<K,
V>
Builds ExpiringMap instances. Defaults to ExpirationPolicy.CREATED, expiration of 60 TimeUnit.SECONDS and
a maxSize of Integer.MAX_VALUE.
-
方法概要
修饰符和类型方法说明<K1 extends K,V1 extends V>
ExpiringMap.Builder<K1,V1> asyncExpirationListener(ExpirationListener<? super K1, ? super V1> listener) Configures the expiration listener which will receive asynchronous notifications upon each map entry's expiration.<K1 extends K,V1 extends V>
ExpiringMap.Builder<K1,V1> asyncExpirationListeners(List<ExpirationListener<? super K1, ? super V1>> listeners) Configures the expiration listeners which will receive asynchronous notifications upon each map entry's expiration.<K1 extends K,V1 extends V>
ExpiringMap<K1,V1> build()Builds and returns an expiring map.<K1 extends K,V1 extends V>
ExpiringMap.Builder<K1,V1> entryLoader(EntryLoader<? super K1, ? super V1> loader) Sets the EntryLoader to use when loading entries.expiration(long duration, TimeUnit timeUnit) Sets the default map entry expiration.<K1 extends K,V1 extends V>
ExpiringMap.Builder<K1,V1> expirationListener(ExpirationListener<? super K1, ? super V1> listener) Configures the expiration listener that will receive notifications upon each map entry's expiration.<K1 extends K,V1 extends V>
ExpiringMap.Builder<K1,V1> expirationListeners(List<ExpirationListener<? super K1, ? super V1>> listeners) Configures the expiration listeners which will receive notifications upon each map entry's expiration.expirationPolicy(ExpirationPolicy expirationPolicy) Configures the map entry expiration policy.<K1 extends K,V1 extends V>
ExpiringMap.Builder<K1,V1> expiringEntryLoader(ExpiringEntryLoader<? super K1, ? super V1> loader) Sets the ExpiringEntryLoader to use when loading entries and configuresvariable expiration.maxSize(int maxSize) Sets the maximum size of the map.Allows for map entries to have individual expirations and for expirations to be changed.
-
方法详细资料
-
build
Builds and returns an expiring map.- 类型参数:
K1- Key typeV1- Value type- 返回:
- K1,V1
-
expiration
Sets the default map entry expiration.- 参数:
duration- the length of time after an entry is created that it should be removedtimeUnit- the unit thatdurationis expressed in- 返回:
- Builder
- 抛出:
NullPointerException- iftimeUnitis null
-
maxSize
Sets the maximum size of the map. Once this size has been reached, adding an additional entry will expire the first entry in line for expiration based on the expiration policy.- 参数:
maxSize- The maximum size of the map.- 返回:
- Builder
-
entryLoader
public <K1 extends K,V1 extends V> ExpiringMap.Builder<K1,V1> entryLoader(EntryLoader<? super K1, ? super V1> loader) Sets the EntryLoader to use when loading entries. Either an EntryLoader or ExpiringEntryLoader may be set, not both.- 类型参数:
K1- K1V1- V1- 参数:
loader- to set- 返回:
- K1,V1
- 抛出:
NullPointerException- ifloaderis nullIllegalStateException- if anExpiringEntryLoaderis set
-
expiringEntryLoader
public <K1 extends K,V1 extends V> ExpiringMap.Builder<K1,V1> expiringEntryLoader(ExpiringEntryLoader<? super K1, ? super V1> loader) Sets the ExpiringEntryLoader to use when loading entries and configuresvariable expiration. Either an EntryLoader or ExpiringEntryLoader may be set, not both.- 类型参数:
K1- K1V1- V1- 参数:
loader- to set- 返回:
- K1,V1
- 抛出:
NullPointerException- ifloaderis nullIllegalStateException- if anEntryLoaderis set
-
expirationListener
public <K1 extends K,V1 extends V> ExpiringMap.Builder<K1,V1> expirationListener(ExpirationListener<? super K1, ? super V1> listener) Configures the expiration listener that will receive notifications upon each map entry's expiration. Notifications are delivered synchronously and block map write operations.- 类型参数:
K1- K1V1- V1- 参数:
listener- to set- 返回:
- K1,V1
- 抛出:
NullPointerException- iflisteneris null
-
expirationListeners
public <K1 extends K,V1 extends V> ExpiringMap.Builder<K1,V1> expirationListeners(List<ExpirationListener<? super K1, ? super V1>> listeners) Configures the expiration listeners which will receive notifications upon each map entry's expiration. Notifications are delivered synchronously and block map write operations.- 类型参数:
K1- K1V1- V1- 参数:
listeners- to set- 返回:
- K1,V1
- 抛出:
NullPointerException- iflisteneris null
-
asyncExpirationListener
public <K1 extends K,V1 extends V> ExpiringMap.Builder<K1,V1> asyncExpirationListener(ExpirationListener<? super K1, ? super V1> listener) Configures the expiration listener which will receive asynchronous notifications upon each map entry's expiration.- 类型参数:
K1- K1V1- V1- 参数:
listener- to set- 返回:
- K1,V1
- 抛出:
NullPointerException- iflisteneris null
-
asyncExpirationListeners
public <K1 extends K,V1 extends V> ExpiringMap.Builder<K1,V1> asyncExpirationListeners(List<ExpirationListener<? super K1, ? super V1>> listeners) Configures the expiration listeners which will receive asynchronous notifications upon each map entry's expiration.- 类型参数:
K1- K1V1- V1- 参数:
listeners- to set- 返回:
- K1,V1
- 抛出:
NullPointerException- iflisteneris null
-
expirationPolicy
Configures the map entry expiration policy.- 参数:
expirationPolicy- ExpirationPolicy- 返回:
- Builder
- 抛出:
NullPointerException- ifexpirationPolicyis null
-
variableExpiration
Allows for map entries to have individual expirations and for expirations to be changed.- 返回:
- Builder
-