@Override public LettucePoolingClientConfiguration build() { return new DefaultLettucePoolingClientConfiguration(super.build(), poolConfig); } }
@Override public LettuceReactiveRedisConnection getReactiveConnection() { return getShareNativeConnection() ? new LettuceReactiveRedisConnection(getSharedReactiveConnection(), reactiveConnectionProvider) : new LettuceReactiveRedisConnection(reactiveConnectionProvider); }
/** * Validate the shared connections and reinitialize if invalid. */ public void validateConnection() { getOrCreateSharedConnection().validateConnection(); getOrCreateSharedReactiveConnection().validateConnection(); }
public RedisConnection getConnection() { if (isClusterAware()) { return getClusterConnection(); } LettuceConnection connection; if (pool != null) { connection = new LettuceConnection(getSharedConnection(), getTimeout(), null, pool, getDatabase()); } else { connection = new LettuceConnection(getSharedConnection(), connectionProvider, getTimeout(), getDatabase()); } connection.setConvertPipelineAndTxResults(convertPipelineAndTxResults); return connection; }
@Override public RedisClusterConnection getClusterConnection() { if (!isClusterAware()) { throw new InvalidDataAccessApiUsageException("Cluster is not configured!"); } RedisClusterClient clusterClient = (RedisClusterClient) client; return getShareNativeConnection() ? new LettuceClusterConnection( (StatefulRedisClusterConnection<byte[], byte[]>) getOrCreateSharedConnection().getConnection(), connectionProvider, clusterClient, clusterCommandExecutor, clientConfiguration.getCommandTimeout()) : new LettuceClusterConnection(null, connectionProvider, clusterClient, clusterCommandExecutor, clientConfiguration.getCommandTimeout()); }
@Override public LettucePoolingSslClientConfigurationBuilder useSsl() { super.useSsl(); return new LettucePoolingSslClientConfigurationBuilder(this); }
/** * Initialize the shared connection if {@link #getShareNativeConnection() native connection sharing} is enabled and * reset any previously existing connection. */ public void initConnection() { resetConnection(); getSharedConnection(); getSharedReactiveConnection(); }
private LettuceConnectionProvider createConnectionProvider(AbstractRedisClient client, RedisCodec<?, ?> codec) { LettuceConnectionProvider connectionProvider = doCreateConnectionProvider(client, codec); if (this.clientConfiguration instanceof LettucePoolingClientConfiguration) { return new LettucePoolingConnectionProvider(connectionProvider, (LettucePoolingClientConfiguration) this.clientConfiguration); } return connectionProvider; }
@SuppressWarnings("unchecked") private StatefulRedisSentinelConnection<String, String> getConnection(RedisNode sentinel) { return ((TargetAware) connectionProvider).getConnection(StatefulRedisSentinelConnection.class, getRedisURI(sentinel)); }
/** * {@link #close()} the current connection and open a new pub/sub connection to the Redis server. * * @return never {@literal null}. */ @SuppressWarnings("unchecked") protected StatefulRedisPubSubConnection<byte[], byte[]> switchToPubSub() { close(); return connectionProvider.getConnection(StatefulRedisPubSubConnection.class); }
@Override protected RedisSentinelConnection getSentinelConnection(RedisNode sentinel) { StatefulRedisSentinelConnection<String, String> connection = getConnection(sentinel); return new LettuceSentinelConnection(connection); }
@Override public Cursor<byte[]> scan(RedisClusterNode node, ScanOptions options) { return doGetClusterKeyCommands().scan(node, options); }
@Override public Set<byte[]> keys(RedisClusterNode node, byte[] pattern) { return doGetClusterKeyCommands().keys(node, pattern); }
@Override public List<RedisClusterNode> clusterGetNodes() { return LettuceConverters.partitionsToClusterNodes(getPartitions()); }
/** * 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)); }
/** * 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} 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)); }
/** * Creates a new {@link LettucePoolingClientConfigurationBuilder} to build {@link LettucePoolingClientConfiguration} * to be used with the Lettuce client. * * @return a new {@link LettucePoolingClientConfigurationBuilder} to build {@link LettucePoolingClientConfiguration}. */ static LettucePoolingClientConfigurationBuilder builder() { return new LettucePoolingClientConfigurationBuilder(); }
@Override public LettucePoolingClientConfiguration build() { return (LettucePoolingClientConfiguration) super.build(); } }
/** * Create a new {@link LettuceResultBuilder} given {@link Future}. * * @param response must not be {@literal null}. * @param <T> native response type. * @param <R> resulting response type. * @return the new {@link LettuceResultBuilder}. */ static <T, R> LettuceResultBuilder<T, R> forResponse(Future<T> response) { return new LettuceResultBuilder<>(response); }