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:
  • StatefulConnection
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Extension to LettuceConnectionProvider for providers that allow connection creation to specific nodes.
  • Method Summary

    Modifier and Type
    Method
    Description
    default <T extends io.lettuce.core.api.StatefulConnection<?, ?>>
    T
    getConnection(Class<T> connectionType)
    Request a connection given connectionType.
    <T extends io.lettuce.core.api.StatefulConnection<?, ?>>
    CompletionStage<T>
    getConnectionAsync(Class<T> connectionType)
    Request asynchronously a connection given connectionType.
    default void
    release(io.lettuce.core.api.StatefulConnection<?,?> connection)
    Release the connection.
    releaseAsync(io.lettuce.core.api.StatefulConnection<?,?> connection)
    Release asynchronously the connection.
  • Method Details

    • getConnection

      default <T extends io.lettuce.core.api.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 io.lettuce.core.api.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(io.lettuce.core.api.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(io.lettuce.core.api.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