/** * Release the {@link StatefulConnection connection}. Closes connection {@link StatefulConnection#close()} by default. * Implementations may choose whether they override this method and return the connection to a pool. * * @param connection must not be {@literal null}. */ default void release(StatefulConnection<?, ?> connection) { LettuceFutureUtils.join(releaseAsync(connection)); }
/** * Request a connection given {@code connectionType}. Providing a connection type allows specialization to provide a * more specific connection type. * * @param connectionType must not be {@literal null}. * @return the requested connection. Must be {@link #release(StatefulConnection) released} if the connection is no * longer in use. */ default <T extends StatefulConnection<?, ?>> T getConnection(Class<T> connectionType) { return LettuceFutureUtils.join(getConnectionAsync(connectionType)); }
/** * Request a connection given {@code connectionType} for a specific {@link RedisURI}. Providing a connection type * allows specialization to provide a more specific connection type. * * @param connectionType must not be {@literal null}. * @param redisURI must not be {@literal null}. * @return the requested connection. */ default <T extends StatefulConnection<?, ?>> T getConnection(Class<T> connectionType, RedisURI redisURI) { return LettuceFutureUtils.join(getConnectionAsync(connectionType, redisURI)); }
/** * Close connection (blocking call). */ void close() { if (state.compareAndSet(State.INITIAL, CLOSING) || state.compareAndSet(State.CONNECTION_REQUESTED, CLOSING)) { StatefulConnection<ByteBuffer, ByteBuffer> connection = this.connection; this.connection = null; if (connection != null) { LettuceFutureUtils.join(connectionProvider.releaseAsync(connection)); } state.set(State.CLOSED); } }