Package io.lettuce.core
Class RedisURI.Builder
- java.lang.Object
-
- io.lettuce.core.RedisURI.Builder
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RedisURI
build()
static RedisURI.Builder
redis(String host)
Set Redis host.static RedisURI.Builder
redis(String host, int port)
Set Redis host and port.static RedisURI.Builder
sentinel(String host)
Set Sentinel host.static RedisURI.Builder
sentinel(String host, int port)
Set Sentinel host and port.static RedisURI.Builder
sentinel(String host, int port, String masterId)
Set Sentinel host, port and master id.static RedisURI.Builder
sentinel(String host, int port, String masterId, CharSequence password)
Deprecated.since 6.0, usesentinel(String, int, String)
andwithAuthentication(String, CharSequence)
instead.static RedisURI.Builder
sentinel(String host, String masterId)
Set Sentinel host and master id.static RedisURI.Builder
socket(String socket)
Set Redis socket.RedisURI.Builder
withAuthentication(RedisCredentialsProvider credentialsProvider)
Configures authentication.RedisURI.Builder
withAuthentication(RedisURI source)
Apply authentication from anotherRedisURI
.RedisURI.Builder
withAuthentication(String username, char[] password)
Configures authentication.RedisURI.Builder
withAuthentication(String username, CharSequence password)
Configures authentication.RedisURI.Builder
withClientName(String clientName)
Configures a client name.RedisURI.Builder
withDatabase(int database)
Configures the database number.RedisURI.Builder
withHost(String host)
Adds host information to the builder.RedisURI.Builder
withLibraryName(String libraryName)
Configures a library name.RedisURI.Builder
withLibraryVersion(String libraryVersion)
Configures a library version.RedisURI.Builder
withPassword(char[] password)
Configures authentication.RedisURI.Builder
withPassword(CharSequence password)
Configures authentication.RedisURI.Builder
withPassword(String password)
Deprecated.since 6.0.RedisURI.Builder
withPort(int port)
Adds port information to the builder.RedisURI.Builder
withSentinel(RedisURI redisURI)
Add a withSentinel RedisURI to the existing builder.RedisURI.Builder
withSentinel(String host)
Add a withSentinel host to the existing builder.RedisURI.Builder
withSentinel(String host, int port)
Add a withSentinel host/port to the existing builder.RedisURI.Builder
withSentinel(String host, int port, CharSequence password)
Add a withSentinel host/port and Sentinel authentication to the existing builder.RedisURI.Builder
withSentinelMasterId(String sentinelMasterId)
Configures a sentinel master Id.RedisURI.Builder
withSsl(boolean ssl)
Adds ssl information to the builder.RedisURI.Builder
withSsl(RedisURI source)
Apply authentication from anotherRedisURI
.RedisURI.Builder
withStartTls(boolean startTls)
Enables/disables StartTLS when using SSL.RedisURI.Builder
withTimeout(Duration timeout)
Configures a timeout.RedisURI.Builder
withVerifyPeer(boolean verifyPeer)
Enables/disables peer verification.RedisURI.Builder
withVerifyPeer(SslVerifyMode verifyMode)
Configures peer verification mode.
-
-
-
Method Detail
-
socket
public static RedisURI.Builder socket(String socket)
Set Redis socket. Creates a new builder.- Parameters:
socket
- the host name- Returns:
- new builder with Redis socket.
-
redis
public static RedisURI.Builder redis(String host)
Set Redis host. Creates a new builder.- Parameters:
host
- the host name- Returns:
- new builder with Redis host/port.
-
redis
public static RedisURI.Builder redis(String host, int port)
Set Redis host and port. Creates a new builder- Parameters:
host
- the host nameport
- the port- Returns:
- new builder with Redis host/port.
-
sentinel
public static RedisURI.Builder sentinel(String host)
Set Sentinel host. Creates a new builder.- Parameters:
host
- the host name- Returns:
- new builder with Sentinel host/port.
-
sentinel
public static RedisURI.Builder sentinel(String host, int port)
Set Sentinel host and port. Creates a new builder.- Parameters:
host
- the host nameport
- the port- Returns:
- new builder with Sentinel host/port.
-
sentinel
public static RedisURI.Builder sentinel(String host, String masterId)
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
public static RedisURI.Builder sentinel(String host, int port, String masterId)
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
public RedisURI.Builder withSentinel(String host)
Add a withSentinel host to the existing builder.- Parameters:
host
- the host name- Returns:
- the builder
-
withSentinel
public RedisURI.Builder withSentinel(String host, int port)
Add a withSentinel host/port to the existing builder.- Parameters:
host
- the host nameport
- the port- Returns:
- the builder
-
withSentinel
public RedisURI.Builder withSentinel(String host, int port, CharSequence password)
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
public RedisURI.Builder withSentinel(RedisURI redisURI)
Add a withSentinel RedisURI to the existing builder.- Parameters:
redisURI
- the sentinel URI- Returns:
- the builder
- Since:
- 5.2
-
withHost
public RedisURI.Builder withHost(String host)
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
public RedisURI.Builder withPort(int port)
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
public RedisURI.Builder withSsl(RedisURI source)
Apply authentication from anotherRedisURI
. The SSL settings of thesource
URI 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
public RedisURI.Builder withSsl(boolean ssl)
Adds ssl information to the builder. Sets SSL also for already configured Redis Sentinel nodes.- Parameters:
ssl
-true
if use SSL- Returns:
- the builder
-
withStartTls
public RedisURI.Builder withStartTls(boolean startTls)
Enables/disables StartTLS when using SSL. Sets StartTLS also for already configured Redis Sentinel nodes.- Parameters:
startTls
-true
if use StartTLS- Returns:
- the builder
-
withVerifyPeer
public RedisURI.Builder withVerifyPeer(boolean verifyPeer)
Enables/disables peer verification. Sets peer verification also for already configured Redis Sentinel nodes.- Parameters:
verifyPeer
-true
to verify hosts when using SSL- Returns:
- the builder
-
withVerifyPeer
public RedisURI.Builder withVerifyPeer(SslVerifyMode verifyMode)
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
public RedisURI.Builder withDatabase(int database)
Configures the database number.- Parameters:
database
- the database number- Returns:
- the builder
-
withClientName
public RedisURI.Builder withClientName(String clientName)
Configures a client name. Sets client name also for already configured Redis Sentinel nodes.- Parameters:
clientName
- the client name- Returns:
- the builder
-
withLibraryName
public RedisURI.Builder withLibraryName(String libraryName)
Configures a library name. Sets library name also for already configured Redis Sentinel nodes.- Parameters:
libraryName
- the library name- Returns:
- the builder
- Since:
- 6.3
-
withLibraryVersion
public RedisURI.Builder withLibraryVersion(String libraryVersion)
Configures a library version. Sets library version also for already configured Redis Sentinel nodes.- Parameters:
libraryVersion
- the library version- Returns:
- the builder
- Since:
- 6.3
-
withAuthentication
public RedisURI.Builder withAuthentication(String username, CharSequence password)
Configures authentication.- Parameters:
username
- the user namepassword
- the password name- Returns:
- the builder
- Since:
- 6.0
-
withAuthentication
public RedisURI.Builder withAuthentication(RedisURI source)
Apply authentication from anotherRedisURI
. The authentication settings of thesource
URI will be applied to this builder.- Parameters:
source
- must not benull
.- Since:
- 6.0
-
withAuthentication
public RedisURI.Builder withAuthentication(String username, char[] password)
Configures authentication. Empty password is supported (although not recommended for security reasons).- Parameters:
username
- the user namepassword
- the password name- Returns:
- the builder
- Since:
- 6.0
-
withAuthentication
public RedisURI.Builder withAuthentication(RedisCredentialsProvider credentialsProvider)
Configures authentication.- Parameters:
credentialsProvider
- must not benull
.- Since:
- 6.2
-
withPassword
@Deprecated public RedisURI.Builder withPassword(String password)
Deprecated.since 6.0. UsewithPassword(CharSequence)
orwithPassword(char[])
to avoid String caching.Configures authentication. Empty password is supported (although not recommended for security reasons).This method is deprecated as of Lettuce 6.0. The reason is that
String
has a strong caching affinity and the JVM cannot easily GCString
instances. Therefore, we suggest using eitherchar[]
or a customCharSequence
(e.g.StringBuilder
or netty'sAsciiString
).- Parameters:
password
- the password- Returns:
- the builder
-
withPassword
public RedisURI.Builder withPassword(CharSequence password)
Configures authentication. Empty password is supported (although not recommended for security reasons).- Parameters:
password
- the password- Returns:
- the builder
- Since:
- 6.0
-
withPassword
public RedisURI.Builder withPassword(char[] password)
Configures authentication. Empty password is supported (although not recommended for security reasons).- Parameters:
password
- the password- Returns:
- the builder
- Since:
- 4.4
-
withTimeout
public RedisURI.Builder withTimeout(Duration timeout)
Configures a timeout.- Parameters:
timeout
- must not benull
or negative.- Returns:
- the builder
-
withSentinelMasterId
public RedisURI.Builder withSentinelMasterId(String sentinelMasterId)
Configures a sentinel master Id.- Parameters:
sentinelMasterId
- sentinel master id, must not be empty ornull
- Returns:
- the builder
-
build
public RedisURI build()
- Returns:
- the RedisURI.
-
-