public class RedisURI extends Object implements Serializable, ConnectionPoint
RedisURI
:
RedisURI.create("redis://localhost/");
create(String)
for more options
RedisURI.Builder.redis("localhost", 6379).auth("password").database(1).build();
RedisURI.Builder.redis(String)
and
RedisURI.Builder.sentinel(String)
for more options.
new RedisURI("localhost", 6379, 60, TimeUnit.SECONDS);
RedisURI uri = new RedisURI();
uri.setHost("localhost");
redisRedis Standalone (SSL)://
[password@]host [:
port][/
database][?
[timeout=timeout[d|h|m|s|ms|us|ns]] [ &database=database]]
redissRedis Standalone (Unix Domain Sockets)://
[password@]host [:
port][/
database][?
[timeout=timeout[d|h|m|s|ms|us|ns]] [ &database=database]]
redis-socketRedis Sentinel://
[password@]path[?
[timeout=timeout[d|h|m|s|ms|us|ns]][&database=database]]
redis-sentinel://
[password@]host1 [:
port1][, host2 [:
port2]][, hostN [:
portN]][/
database][?
[timeout=timeout[d|h|m|s|ms|us|ns]] [ &sentinelMasterId=sentinelMasterId] [&database=database]]
Schemes
Timeout units
Hint: The database parameter within the query part has higher precedence than the database in the path.
RedisURI supports Redis Standalone, Redis Sentinel and Redis Cluster with plain, SSL, TLS and unix domain socket connections.Modifier and Type | Class and Description |
---|---|
static class |
RedisURI.Builder
Builder for Redis URI.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_REDIS_PORT
The default redis port.
|
static int |
DEFAULT_SENTINEL_PORT
The default sentinel port.
|
static long |
DEFAULT_TIMEOUT
Default timeout: 60 sec
|
static TimeUnit |
DEFAULT_TIMEOUT_UNIT |
static String |
PARAMETER_NAME_DATABASE |
static String |
PARAMETER_NAME_DATABASE_ALT |
static String |
PARAMETER_NAME_SENTINEL_MASTER_ID |
static String |
PARAMETER_NAME_TIMEOUT |
static Map<String,TimeUnit> |
TIME_UNIT_MAP |
static String |
URI_SCHEME_REDIS |
static String |
URI_SCHEME_REDIS_SECURE |
static String |
URI_SCHEME_REDIS_SECURE_ALT |
static String |
URI_SCHEME_REDIS_SENTINEL |
static String |
URI_SCHEME_REDIS_SOCKET |
static String |
URI_SCHEME_REDIS_SOCKET_ALT |
static String |
URI_SCHEME_REDIS_TLS_ALT |
Constructor and Description |
---|
RedisURI()
Default empty constructor.
|
RedisURI(String host,
int port,
long timeout,
TimeUnit unit)
Constructor with host/port and timeout.
|
Modifier and Type | Method and Description |
---|---|
static RedisURI |
create(String uri)
Create a Redis URI from an URI string.
|
static RedisURI |
create(String host,
int port)
Create a Redis URI from host and port.
|
static RedisURI |
create(URI uri)
Create a Redis URI from an URI string:
The uri must follow conventions of
URI |
boolean |
equals(Object o) |
int |
getDatabase() |
String |
getHost()
Returns the host that should represent the hostname or IPv4/IPv6 literal.
|
char[] |
getPassword() |
int |
getPort()
Get the current port number.
|
SocketAddress |
getResolvedAddress() |
String |
getSentinelMasterId() |
List<RedisURI> |
getSentinels() |
String |
getSocket()
Get the socket path.
|
long |
getTimeout() |
TimeUnit |
getUnit() |
int |
hashCode() |
boolean |
isSsl() |
boolean |
isStartTls() |
boolean |
isVerifyPeer() |
void |
setDatabase(int database) |
void |
setHost(String host) |
void |
setPassword(String password) |
void |
setPort(int port) |
void |
setSentinelMasterId(String sentinelMasterId) |
void |
setSocket(String socket) |
void |
setSsl(boolean ssl) |
void |
setStartTls(boolean startTls) |
void |
setTimeout(long timeout) |
void |
setUnit(TimeUnit unit) |
void |
setVerifyPeer(boolean verifyPeer) |
String |
toString() |
URI |
toURI()
Creates an URI based on the RedisURI.
|
public static final String URI_SCHEME_REDIS_SENTINEL
public static final String URI_SCHEME_REDIS
public static final String URI_SCHEME_REDIS_SECURE
public static final String URI_SCHEME_REDIS_SECURE_ALT
public static final String URI_SCHEME_REDIS_TLS_ALT
public static final String URI_SCHEME_REDIS_SOCKET
public static final String URI_SCHEME_REDIS_SOCKET_ALT
public static final String PARAMETER_NAME_TIMEOUT
public static final String PARAMETER_NAME_DATABASE
public static final String PARAMETER_NAME_DATABASE_ALT
public static final String PARAMETER_NAME_SENTINEL_MASTER_ID
public static final int DEFAULT_SENTINEL_PORT
public static final int DEFAULT_REDIS_PORT
public static final long DEFAULT_TIMEOUT
public static final TimeUnit DEFAULT_TIMEOUT_UNIT
public static RedisURI create(String host, int port)
host
- the hostport
- the portRedisURI
containing details from the host
and port
.public static RedisURI create(String uri)
URI
uri
- The URI string.RedisURI
containing details from the URI.public static RedisURI create(URI uri)
URI
uri
- The URI.RedisURI
containing details from the URI.public String getHost()
ConnectionPoint
getHost
in interface ConnectionPoint
public void setHost(String host)
public String getSentinelMasterId()
public void setSentinelMasterId(String sentinelMasterId)
public int getPort()
ConnectionPoint
getPort
in interface ConnectionPoint
public void setPort(int port)
public String getSocket()
ConnectionPoint
getSocket
in interface ConnectionPoint
public void setSocket(String socket)
public char[] getPassword()
public void setPassword(String password)
public long getTimeout()
public void setTimeout(long timeout)
public TimeUnit getUnit()
public void setUnit(TimeUnit unit)
public int getDatabase()
public void setDatabase(int database)
public boolean isSsl()
public void setSsl(boolean ssl)
public boolean isVerifyPeer()
public void setVerifyPeer(boolean verifyPeer)
public boolean isStartTls()
public void setStartTls(boolean startTls)
public URI toURI()
public SocketAddress getResolvedAddress()
SocketAddress
based either on host/port or the socket.Copyright © 2016. All rights reserved.