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.
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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceExtension toLettuceConnectionProviderfor providers that allow connection creation to specific nodes. -
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends io.lettuce.core.api.StatefulConnection<?,?>>
TgetConnection(Class<T> connectionType) Request a connection givenconnectionType.<T extends io.lettuce.core.api.StatefulConnection<?,?>>
CompletionStage<T>getConnectionAsync(Class<T> connectionType) Request asynchronously a connection givenconnectionType.default voidrelease(io.lettuce.core.api.StatefulConnection<?, ?> connection) Release theconnection.default CompletableFuture<Void>releaseAsync(io.lettuce.core.api.StatefulConnection<?, ?> connection) Release asynchronously theconnection.
-
Method Details
-
getConnection
default <T extends io.lettuce.core.api.StatefulConnection<?,?>> T getConnection(Class<T> connectionType) Request a connection givenconnectionType. 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
releasedif 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 givenconnectionType. Providing a connection type allows specialization to provide a more specific connection type.- Parameters:
connectionType- must not be null.- Returns:
- a
CompletionStagethat is notified with the connection progress. Must bereleasedif the connection is no longer in use. - Since:
- 2.2
-
release
default void release(io.lettuce.core.api.StatefulConnection<?, ?> connection) Release theconnection. Closes connectionStatefulConnection.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 theconnection. Closes connectionStatefulConnection.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
futurenotified once the connection is released. - Since:
- 2.2
-