类 ExpiringMap.Builder<K,V>

java.lang.Object
com.sh.util.concurrent.expiringmap.ExpiringMap.Builder<K,V>
封闭类:
ExpiringMap<K,V>

public static final class ExpiringMap.Builder<K,V> extends Object
Builds ExpiringMap instances. Defaults to ExpirationPolicy.CREATED, expiration of 60 TimeUnit.SECONDS and a maxSize of Integer.MAX_VALUE.
  • 方法详细资料

    • build

      public <K1 extends K, V1 extends V> ExpiringMap<K1,V1> build()
      Builds and returns an expiring map.
      类型参数:
      K1 - Key type
      V1 - Value type
      返回:
      K1,V1
    • expiration

      public ExpiringMap.Builder<K,V> expiration(long duration, TimeUnit timeUnit)
      Sets the default map entry expiration.
      参数:
      duration - the length of time after an entry is created that it should be removed
      timeUnit - the unit that duration is expressed in
      返回:
      Builder
      抛出:
      NullPointerException - if timeUnit is null
    • maxSize

      public ExpiringMap.Builder<K,V> maxSize(int 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 - K1
      V1 - V1
      参数:
      loader - to set
      返回:
      K1,V1
      抛出:
      NullPointerException - if loader is null
      IllegalStateException - if an ExpiringEntryLoader is 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 configures variable expiration. Either an EntryLoader or ExpiringEntryLoader may be set, not both.
      类型参数:
      K1 - K1
      V1 - V1
      参数:
      loader - to set
      返回:
      K1,V1
      抛出:
      NullPointerException - if loader is null
      IllegalStateException - if an EntryLoader is 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 - K1
      V1 - V1
      参数:
      listener - to set
      返回:
      K1,V1
      抛出:
      NullPointerException - if listener is 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 - K1
      V1 - V1
      参数:
      listeners - to set
      返回:
      K1,V1
      抛出:
      NullPointerException - if listener is 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 - K1
      V1 - V1
      参数:
      listener - to set
      返回:
      K1,V1
      抛出:
      NullPointerException - if listener is 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 - K1
      V1 - V1
      参数:
      listeners - to set
      返回:
      K1,V1
      抛出:
      NullPointerException - if listener is null
    • expirationPolicy

      public ExpiringMap.Builder<K,V> expirationPolicy(ExpirationPolicy expirationPolicy)
      Configures the map entry expiration policy.
      参数:
      expirationPolicy - ExpirationPolicy
      返回:
      Builder
      抛出:
      NullPointerException - if expirationPolicy is null
    • variableExpiration

      public ExpiringMap.Builder<K,V> variableExpiration()
      Allows for map entries to have individual expirations and for expirations to be changed.
      返回:
      Builder