java.lang.Object
io.lettuce.core.RedisURI.Builder
- Enclosing class:
- RedisURI
public static class RedisURI.Builder extends Object
Builder for Redis URI.
-
Method Summary
Modifier and Type Method Description RedisURIbuild()static RedisURI.Builderredis(String host)Set Redis host.static RedisURI.Builderredis(String host, int port)Set Redis host and port.static RedisURI.Buildersentinel(String host)Set Sentinel host.static RedisURI.Buildersentinel(String host, int port)Set Sentinel host and port.static RedisURI.Buildersentinel(String host, int port, String masterId)Set Sentinel host, port and master id.static RedisURI.Buildersentinel(String host, int port, String masterId, CharSequence password)Deprecated.static RedisURI.Buildersentinel(String host, String masterId)Set Sentinel host and master id.static RedisURI.Buildersocket(String socket)Set Redis socket.RedisURI.BuilderwithAuthentication(RedisURI source)Apply authentication from anotherRedisURI.RedisURI.BuilderwithAuthentication(String username, char[] password)Configures authentication.RedisURI.BuilderwithAuthentication(String username, CharSequence password)Configures authentication.RedisURI.BuilderwithClientName(String clientName)Configures a client name.RedisURI.BuilderwithDatabase(int database)Configures the database number.RedisURI.BuilderwithHost(String host)Adds host information to the builder.RedisURI.BuilderwithPassword(char[] password)Configures authentication.RedisURI.BuilderwithPassword(CharSequence password)Configures authentication.RedisURI.BuilderwithPassword(String password)Deprecated.since 6.0.RedisURI.BuilderwithPort(int port)Adds port information to the builder.RedisURI.BuilderwithSentinel(RedisURI redisURI)Add a withSentinel RedisURI to the existing builder.RedisURI.BuilderwithSentinel(String host)Add a withSentinel host to the existing builder.RedisURI.BuilderwithSentinel(String host, int port)Add a withSentinel host/port to the existing builder.RedisURI.BuilderwithSentinel(String host, int port, CharSequence password)Add a withSentinel host/port and Sentinel authentication to the existing builder.RedisURI.BuilderwithSentinelMasterId(String sentinelMasterId)Configures a sentinel master Id.RedisURI.BuilderwithSsl(boolean ssl)Adds ssl information to the builder.RedisURI.BuilderwithSsl(RedisURI source)Apply authentication from anotherRedisURI.RedisURI.BuilderwithStartTls(boolean startTls)Enables/disables StartTLS when using SSL.RedisURI.BuilderwithTimeout(Duration timeout)Configures a timeout.RedisURI.BuilderwithVerifyPeer(boolean verifyPeer)Enables/disables peer verification.RedisURI.BuilderwithVerifyPeer(SslVerifyMode verifyMode)Configures peer verification mode.
-
Method Details
-
socket
Set Redis socket. Creates a new builder.- Parameters:
socket- the host name- Returns:
- new builder with Redis socket.
-
redis
Set Redis host. Creates a new builder.- Parameters:
host- the host name- Returns:
- new builder with Redis host/port.
-
redis
Set Redis host and port. Creates a new builder- Parameters:
host- the host nameport- the port- Returns:
- new builder with Redis host/port.
-
sentinel
Set Sentinel host. Creates a new builder.- Parameters:
host- the host name- Returns:
- new builder with Sentinel host/port.
-
sentinel
Set Sentinel host and port. Creates a new builder.- Parameters:
host- the host nameport- the port- Returns:
- new builder with Sentinel host/port.
-
sentinel
Set Sentinel host and master id. Creates a new builder.- Parameters:
host- the host namemasterId- sentinel master id- Returns:
- new builder with Sentinel host/port.
-
sentinel
Set Sentinel host, port and master id. Creates a new builder.- Parameters:
host- the host nameport- the portmasterId- sentinel master id- Returns:
- new builder with Sentinel host/port.
-
sentinel
@Deprecated public static RedisURI.Builder sentinel(String host, int port, String masterId, CharSequence password)Deprecated.since 6.0, usesentinel(String, int, String)andwithAuthentication(String, CharSequence)instead.Set Sentinel host, port, master id and Sentinel authentication. Creates a new builder.- Parameters:
host- the host nameport- the portmasterId- sentinel master idpassword- the Sentinel password (supported since Redis 5.0.1)- Returns:
- new builder with Sentinel host/port.
-
withSentinel
Add a withSentinel host to the existing builder.- Parameters:
host- the host name- Returns:
- the builder
-
withSentinel
Add a withSentinel host/port to the existing builder.- Parameters:
host- the host nameport- the port- Returns:
- the builder
-
withSentinel
Add a withSentinel host/port and Sentinel authentication to the existing builder.- Parameters:
host- the host nameport- the portpassword- the Sentinel password (supported since Redis 5.0.1)- Returns:
- the builder
- Since:
- 5.2
-
withSentinel
Add a withSentinel RedisURI to the existing builder.- Parameters:
redisURI- the sentinel URI- Returns:
- the builder
- Since:
- 5.2
-
withHost
Adds host information to the builder. Does only affect Redis URI, cannot be used with Sentinel connections.- Parameters:
host- the port- Returns:
- the builder
-
withPort
Adds port information to the builder. Does only affect Redis URI, cannot be used with Sentinel connections.- Parameters:
port- the port- Returns:
- the builder
-
withSsl
Apply authentication from anotherRedisURI. The SSL settings of thesourceURI will be applied to this URI. That is in particular SSL usage, peer verification and StartTLS.- Parameters:
source- must not benull.- Returns:
- the builder
- Since:
- 6.0
-
withSsl
Adds ssl information to the builder. Sets SSL also for already configured Redis Sentinel nodes.- Parameters:
ssl-trueif use SSL- Returns:
- the builder
-
withStartTls
Enables/disables StartTLS when using SSL. Sets StartTLS also for already configured Redis Sentinel nodes.- Parameters:
startTls-trueif use StartTLS- Returns:
- the builder
-
withVerifyPeer
Enables/disables peer verification. Sets peer verification also for already configured Redis Sentinel nodes.- Parameters:
verifyPeer-trueto verify hosts when using SSL- Returns:
- the builder
-
withVerifyPeer
Configures peer verification mode. Sets peer verification also for already configured Redis Sentinel nodes.- Parameters:
verifyMode- the mode to verify hosts when using SSL- Returns:
- the builder
- Since:
- 6.1
-
withDatabase
Configures the database number.- Parameters:
database- the database number- Returns:
- the builder
-
withClientName
Configures a client name.- Parameters:
clientName- the client name- Returns:
- the builder
-
withAuthentication
Configures authentication.- Parameters:
username- the user namepassword- the password name- Returns:
- the builder
- Since:
- 6.0
-
withAuthentication
Apply authentication from anotherRedisURI. The authentication settings of thesourceURI will be applied to this builder.- Parameters:
source- must not benull.- Since:
- 6.0
-
withAuthentication
Configures authentication.- Parameters:
username- the user namepassword- the password name- Returns:
- the builder
- Since:
- 6.0
-
withPassword
Deprecated.since 6.0. UsewithPassword(CharSequence)orwithPassword(char[])to avoid String caching.Configures authentication.This method is deprecated as of Lettuce 6.0. The reason is that
Stringhas a strong caching affinity and the JVM cannot easily GCStringinstances. Therefore we suggest using eitherchar[]or a customCharSequence(e.g.StringBuilderor netty'sAsciiString).- Parameters:
password- the password- Returns:
- the builder
-
withPassword
Configures authentication.- Parameters:
password- the password- Returns:
- the builder
- Since:
- 6.0
-
withPassword
Configures authentication.- Parameters:
password- the password- Returns:
- the builder
- Since:
- 4.4
-
withTimeout
Configures a timeout.- Parameters:
timeout- must not benullor negative.- Returns:
- the builder
-
withSentinelMasterId
Configures a sentinel master Id.- Parameters:
sentinelMasterId- sentinel master id, must not be empty ornull- Returns:
- the builder
-
build
- Returns:
- the RedisURI.
-
sentinel(String, int, String)andwithAuthentication(String, CharSequence)instead.