Interface LettuceConnectionProvider

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface LettuceConnectionProvider
Defines a provider for Lettuce connections.

This interface is typically used to encapsulate a native factory which returns a connection of on each invocation.

Connection providers may create a new connection on each invocation or return pooled instances. Each obtained connection must be released through its connection provider to allow disposal or release back to the pool.

Connection providers are usually associated with a RedisCodec to create connections with an appropriate codec.

Since:
2.0
Author:
Mark Paluch, Christoph Strobl
See Also:
  • Method Details

    • getConnection

      default <T extends StatefulConnection<?,?>> T getConnection(Class<T> connectionType)
      Request a connection given connectionType. Providing a connection type allows specialization to provide a more specific connection type.
      Parameters:
      connectionType - must not be null.
      Returns:
      the requested connection. Must be released if the connection is no longer in use.
    • getConnectionAsync

      <T extends StatefulConnection<?,?>> CompletionStage<T> getConnectionAsync(Class<T> connectionType)
      Request asynchronously a connection given connectionType. Providing a connection type allows specialization to provide a more specific connection type.
      Parameters:
      connectionType - must not be null.
      Returns:
      a CompletionStage that is notified with the connection progress. Must be released if the connection is no longer in use.
      Since:
      2.2
    • release

      default void release(StatefulConnection<?,?> connection)
      Release the connection. Closes connection StatefulConnection.close() by default. Implementations may choose whether they override this method and return the connection to a pool.
      Parameters:
      connection - must not be null.
    • releaseAsync

      default CompletableFuture<Void> releaseAsync(StatefulConnection<?,?> connection)
      Release asynchronously the connection. Closes connection StatefulConnection.closeAsync() by default. Implementations may choose whether they override this method and return the connection to a pool.
      Parameters:
      connection - must not be null.
      Returns:
      Close future notified once the connection is released.
      Since:
      2.2