public class RedisOptions extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ENDPOINT
The default redis endpoint =
redis://localhost:6379 |
Constructor and Description |
---|
RedisOptions()
Creates a default configuration object using redis server defaults
|
RedisOptions(JsonObject json)
Copy from JSON constructor.
|
RedisOptions(RedisOptions other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
RedisOptions |
addConnectionString(String connectionString)
Adds a connection string (endpoint) to use while connecting to the redis server.
|
RedisOptions |
addEndpoint(String connectionString)
Deprecated.
see
setConnectionString(String connectionString) for a better naming |
String |
getEndpoint()
Gets the redis endpoint to use
|
List<String> |
getEndpoints()
Gets the list of redis endpoints to use (mostly used while connecting to a cluster)
|
long |
getHashSlotCacheTTL()
Returns the TTL of the hash slot cache.
|
String |
getMasterName()
Get the master name (only considered in HA mode).
|
int |
getMaxNestedArrays()
Tune how much nested arrays are allowed on a redis response.
|
int |
getMaxPoolSize()
Get the maximum size of the connection pool.
|
int |
getMaxPoolWaiting()
Get the maximum number of requests waiting for a connection from the pool.
|
int |
getMaxWaitingHandlers()
The client will always work on pipeline mode, this means that messages can start queueing.
|
NetClientOptions |
getNetClientOptions()
Get the net client options used to connect to the server.
|
String |
getPassword()
Get the default password for cluster/sentinel connections, if not set it will try to
extract it from the current default endpoint.
|
int |
getPoolCleanerInterval()
Get how often the connection pool will be cleaned.
|
String |
getPoolName()
Get the connection pool name to be used for metrics reporting.
|
PoolOptions |
getPoolOptions() |
int |
getPoolRecycleTimeout()
Get how long a connection can exist before it is recycled during connection pool
cleaning.
|
ProtocolVersion |
getPreferredProtocolVersion()
Returns the preferred protocol version to be used during protocol negotiation.
|
RedisRole |
getRole()
Get the role name (only considered in HA mode).
|
TracingPolicy |
getTracingPolicy() |
RedisClientType |
getType()
Get the type of client to be created.
|
RedisReplicas |
getUseReplicas()
Get whether or not to use replica nodes (only considered in Cluster mode).
|
boolean |
isProtocolNegotiation()
Should the client perform
RESP protocol negotiation during the connection handshake. |
RedisOptions |
setConnectionString(String connectionString)
Sets a single connection string (endpoint) to use while connecting to the redis server.
|
RedisOptions |
setEndpoint(String connectionString)
Deprecated.
see
setConnectionString(String connectionString) for a better naming |
RedisOptions |
setEndpoints(List<String> endpoints)
Set the endpoints to use while connecting to the redis server.
|
RedisOptions |
setHashSlotCacheTTL(long hashSlotCacheTTL)
Sets the TTL of the hash slot cache.
|
RedisOptions |
setMasterName(String masterName)
Set the master name (only considered in HA mode).
|
RedisOptions |
setMaxNestedArrays(int maxNestedArrays)
Tune how much nested arrays are allowed on a redis response.
|
RedisOptions |
setMaxPoolSize(int maxPoolSize)
Set the maximum size of the connection pool.
|
RedisOptions |
setMaxPoolWaiting(int maxPoolWaiting)
Set the maximum number of requests waiting for a connection from the pool.
|
RedisOptions |
setMaxWaitingHandlers(int maxWaitingHandlers)
The client will always work on pipeline mode, this means that messages can start queueing.
|
RedisOptions |
setNetClientOptions(NetClientOptions netClientOptions)
Set the net client options to be used while connecting to the redis server.
|
RedisOptions |
setPassword(String password)
Set the default password for cluster/sentinel connections.
|
RedisOptions |
setPoolCleanerInterval(int poolCleanerInterval)
Set how often the connection pool will be cleaned.
|
RedisOptions |
setPoolName(String poolName)
Set the connection pool name to be used for metrics reporting.
|
RedisOptions |
setPoolRecycleTimeout(int poolRecycleTimeout)
Set how long a connection can exist before it is recycled during connection pool
cleaning.
|
RedisOptions |
setPreferredProtocolVersion(ProtocolVersion preferredProtocolVersion)
Sets the preferred protocol version to be used during protocol negotiation.
|
RedisOptions |
setProtocolNegotiation(boolean protocolNegotiation)
Should the client perform
REST protocol negotiation during the connection acquire. |
RedisOptions |
setRole(RedisRole role)
Set the role name (only considered in HA mode).
|
RedisOptions |
setTracingPolicy(TracingPolicy tracingPolicy)
Set the tracing policy for the client behavior when Vert.x has tracing enabled.
|
RedisOptions |
setType(RedisClientType type)
Set the desired client type to be created.
|
RedisOptions |
setUseReplicas(RedisReplicas useReplicas)
Set whether or not to use replica nodes (only considered in Cluster mode).
|
JsonObject |
toJson()
Converts this object to JSON notation.
|
public static final String DEFAULT_ENDPOINT
redis://localhost:6379
public RedisOptions()
public RedisOptions(RedisOptions other)
other
- the object to clone.public RedisOptions(JsonObject json)
json
- source jsonpublic RedisClientType getType()
public RedisOptions setType(RedisClientType type)
type
- the client type.public NetClientOptions getNetClientOptions()
public RedisOptions setNetClientOptions(NetClientOptions netClientOptions)
netClientOptions
- custom net client options.public List<String> getEndpoints()
public String getEndpoint()
public RedisOptions setEndpoints(List<String> endpoints)
endpoints
- list of socket addresses.@Deprecated public RedisOptions addEndpoint(String connectionString)
setConnectionString(String connectionString)
for a better namingconnectionString
- a string URI following the scheme: redis://[username:password@][host][:port][/database]@Deprecated public RedisOptions setEndpoint(String connectionString)
setConnectionString(String connectionString)
for a better namingconnectionString
- a string following the scheme: redis://[username:password@][host][:port][/[database]public RedisOptions addConnectionString(String connectionString)
connectionString
- a string URI following the scheme: redis://[username:password@][host][:port][/database]public RedisOptions setConnectionString(String connectionString)
connectionString
- a string following the scheme: redis://[username:password@][host][:port][/[database].public int getMaxWaitingHandlers()
public RedisOptions setMaxWaitingHandlers(int maxWaitingHandlers)
maxWaitingHandlers
- max allowed queued waiting handlers.public String getMasterName()
public RedisOptions setMasterName(String masterName)
masterName
- the master name.public RedisRole getRole()
public RedisOptions setRole(RedisRole role)
role
- the master name.public RedisReplicas getUseReplicas()
public RedisOptions setUseReplicas(RedisReplicas useReplicas)
useReplicas
- the cluster replica use mode.public int getMaxNestedArrays()
public RedisOptions setMaxNestedArrays(int maxNestedArrays)
maxNestedArrays
- the configured max nested arrays allowance.public TracingPolicy getTracingPolicy()
public RedisOptions setTracingPolicy(TracingPolicy tracingPolicy)
tracingPolicy
- the tracing policypublic PoolOptions getPoolOptions()
public int getPoolCleanerInterval()
A connection is marked invalid if it enters a exception or fatal state or if it exists longer than the recycle timeout.
The return value is in milliseconds. By default, the cleaning interval is 30 seconds. The value of -1 means connection pool cleaning is disabled.
public RedisOptions setPoolCleanerInterval(int poolCleanerInterval)
A connection is marked invalid if it enters a exception or fatal state or if it exists longer than the recycle timeout.
The value is in milliseconds. By default, the cleaning interval is 30 seconds. The value of -1 means connection pool cleaning is disabled.
poolCleanerInterval
- the cleaning interval in milliseconds, or -1 for neverpublic int getMaxPoolSize()
By default, the maximum pool size is 6.
public RedisOptions setMaxPoolSize(int maxPoolSize)
By default, the maximum pool size is 6.
When working with cluster or sentinel, this value should be at least the total number of cluster member (or number of sentinels + 1).
maxPoolSize
- the maximum pool sizepublic int getMaxPoolWaiting()
By default, the maximum number of waiting requests size is 24.
public RedisOptions setMaxPoolWaiting(int maxPoolWaiting)
By default, the maximum number of waiting requests size is 24.
maxPoolWaiting
- the maximum number of waiting requestspublic int getPoolRecycleTimeout()
The value is in milliseconds. By default, the recycle timeout is 3 minutes. The value of -1 means connection recycling is disabled.
public RedisOptions setPoolRecycleTimeout(int poolRecycleTimeout)
The value is in milliseconds. By default, the recycle timeout is 3 minutes. The value of -1 means connection recycling is disabled.
poolRecycleTimeout
- the recycle timeoutpublic String getPassword()
public RedisOptions setPassword(String password)
password
- the default passwordpublic boolean isProtocolNegotiation()
RESP
protocol negotiation during the connection handshake.
By default this is true
, but there are situations when using broken servers it may
be useful to skip this and always fallback to RESP2
without using the HELLO
command.public RedisOptions setProtocolNegotiation(boolean protocolNegotiation)
REST
protocol negotiation during the connection acquire.
By default this is true
, but there are situations when using broken servers it may
be useful to skip this and always fallback to RESP2
without using the HELLO
command.protocolNegotiation
- false to disable HELLO
(not recommended) unless reasons...public ProtocolVersion getPreferredProtocolVersion()
public RedisOptions setPreferredProtocolVersion(ProtocolVersion preferredProtocolVersion)
preferredProtocolVersion
- preferred protocol versionpublic String getPoolName()
public RedisOptions setPoolName(String poolName)
poolName
- the pool namepublic long getHashSlotCacheTTL()
The TTL is expressed in milliseconds. Defaults to 1000 millis (1 second).
public RedisOptions setHashSlotCacheTTL(long hashSlotCacheTTL)
The TTL is expressed in milliseconds. Defaults to 1000 millis (1 second).
hashSlotCacheTTL
- the TTL of the hash slot cache, in millispublic JsonObject toJson()
Copyright © 2024 Eclipse. All rights reserved.