Module lettuce.core

Class BoundedPoolConfig.Builder

java.lang.Object
io.lettuce.core.support.BasePoolConfig.Builder
io.lettuce.core.support.BoundedPoolConfig.Builder
Enclosing class:
BoundedPoolConfig

public static class BoundedPoolConfig.Builder
extends BasePoolConfig.Builder
Builder for BoundedPoolConfig.
  • Constructor Details

    • Builder

      protected Builder()
  • Method Details

    • testOnCreate

      public BoundedPoolConfig.Builder testOnCreate()
      Description copied from class: BasePoolConfig.Builder
      Enables validation of objects before being returned from the acquire method. Validation is performed by the AsyncObjectFactory.validate(Object) method of the factory associated with the pool. If the object fails to validate, then acquire will fail.
      Overrides:
      testOnCreate in class BasePoolConfig.Builder
      Returns:
      this BasePoolConfig.Builder.
    • testOnCreate

      public BoundedPoolConfig.Builder testOnCreate​(boolean testOnCreate)
      Description copied from class: BasePoolConfig.Builder
      Configures whether objects created for the pool will be validated before being returned from the acquire method. Validation is performed by the AsyncObjectFactory.validate(Object) method of the factory associated with the pool. If the object fails to validate, then acquire will fail.
      Overrides:
      testOnCreate in class BasePoolConfig.Builder
      Parameters:
      testOnCreate - true if newly created objects should be validated before being returned from the acquire method. true to enable test on creation.
      Returns:
      this BasePoolConfig.Builder.
    • testOnAcquire

      public BoundedPoolConfig.Builder testOnAcquire()
      Description copied from class: BasePoolConfig.Builder
      Enables validation of objects before being returned from the acquire method. Validation is performed by the AsyncObjectFactory.validate(Object) method of the factory associated with the pool. If the object fails to validate, it will be removed from the pool and destroyed, and a new attempt will be made to borrow an object from the pool.
      Overrides:
      testOnAcquire in class BasePoolConfig.Builder
      Returns:
      this BasePoolConfig.Builder.
    • testOnAcquire

      public BoundedPoolConfig.Builder testOnAcquire​(boolean testOnAcquire)
      Description copied from class: BasePoolConfig.Builder
      Configures whether objects acquired from the pool will be validated before being returned from the acquire method. Validation is performed by the AsyncObjectFactory.validate(Object) method of the factory associated with the pool. If the object fails to validate, it will be removed from the pool and destroyed, and a new attempt will be made to borrow an object from the pool.
      Overrides:
      testOnAcquire in class BasePoolConfig.Builder
      Parameters:
      testOnAcquire - true if objects should be validated before being returned from the acquire method.
      Returns:
      this BasePoolConfig.Builder.
    • testOnRelease

      public BoundedPoolConfig.Builder testOnRelease()
      Description copied from class: BasePoolConfig.Builder
      Enables validation of objects when they are returned to the pool via the release method. Validation is performed by the AsyncObjectFactory.validate(Object) method of the factory associated with the pool. Returning objects that fail validation are destroyed rather then being returned the pool.
      Overrides:
      testOnRelease in class BasePoolConfig.Builder
      Returns:
      this BasePoolConfig.Builder.
    • testOnRelease

      public BoundedPoolConfig.Builder testOnRelease​(boolean testOnRelease)
      Description copied from class: BasePoolConfig.Builder
      Configures whether objects borrowed from the pool will be validated when they are returned to the pool via the release method. Validation is performed by the AsyncObjectFactory.validate(Object) method of the factory associated with the pool. Returning objects that fail validation are destroyed rather then being returned the pool.
      Overrides:
      testOnRelease in class BasePoolConfig.Builder
      Parameters:
      testOnRelease - true if objects should be validated on return to the pool via the release method.
      Returns:
      this BasePoolConfig.Builder.
    • maxTotal

      public BoundedPoolConfig.Builder maxTotal​(int maxTotal)
      Configures the maximum number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time. When negative, there is no limit to the number of objects that can be managed by the pool at one time.
      Parameters:
      maxTotal - maximum number of objects that can be allocated by the pool.
      Returns:
      this BoundedPoolConfig.Builder.
    • maxIdle

      public BoundedPoolConfig.Builder maxIdle​(int maxIdle)
      Returns the cap on the number of "idle" instances in the pool. If maxIdle is set too low on heavily loaded systems it is possible you will see objects being destroyed and almost immediately new objects being created. This is a result of the active threads momentarily returning objects faster than they are requesting them them, causing the number of idle objects to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is a good starting point.
      Parameters:
      maxIdle - the cap on the number of "idle" instances in the pool.
      Returns:
      this BoundedPoolConfig.Builder.
    • minIdle

      public BoundedPoolConfig.Builder minIdle​(int minIdle)
      Configures the minimum number of idle objects to maintain in the pool. If this is the case, an attempt is made to ensure that the pool has the required minimum number of instances during idle object eviction runs.
      Parameters:
      minIdle - minimum number of idle objects to maintain in the pool.
      Returns:
      this BoundedPoolConfig.Builder.
    • build

      public BoundedPoolConfig build()
      Build a new BasePoolConfig object.
      Returns:
      a new BasePoolConfig object.