public class Connection
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
static class |
Connection.Builder |
| Modifier and Type | Field and Description |
|---|---|
protected RedisProtocol |
protocol
The RESP protocol established for this connection.
|
protected java.lang.String |
server |
protected java.lang.String |
version |
| Modifier | Constructor and Description |
|---|---|
|
Connection() |
protected |
Connection(Connection.Builder builder) |
|
Connection(HostAndPort hostAndPort) |
|
Connection(HostAndPort hostAndPort,
JedisClientConfig clientConfig) |
|
Connection(JedisSocketFactory socketFactory) |
|
Connection(JedisSocketFactory socketFactory,
JedisClientConfig clientConfig) |
|
Connection(java.lang.String host,
int port) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addPushConsumer(PushConsumer consumer) |
static Connection.Builder |
builder() |
void |
close() |
void |
connect() |
void |
disconnect()
Close the socket and disconnect the server.
|
protected byte[] |
encodeToBytes(char[] chars) |
java.lang.Object |
executeCommand(CommandArguments args) |
<T> T |
executeCommand(CommandObject<T> commandObject) |
java.lang.Object |
executeCommand(ProtocolCommand cmd) |
protected void |
flush() |
void |
forceDisconnect() |
protected AuthXManager |
getAuthXManager() |
byte[] |
getBinaryBulkReply() |
java.util.List<byte[]> |
getBinaryMultiBulkReply() |
java.lang.String |
getBulkReply() |
HostAndPort |
getHostAndPort()
Returns the host and port of the Redis server this connection is connected to.
|
java.util.List<java.lang.Long> |
getIntegerMultiBulkReply() |
java.lang.Long |
getIntegerReply() |
java.util.List<java.lang.Object> |
getMany(int count) |
java.util.List<java.lang.String> |
getMultiBulkReply() |
java.util.List<java.lang.Object> |
getObjectMultiBulkReply() |
java.lang.Object |
getOne() |
RedisProtocol |
getRedisProtocol()
Returns the RESP protocol established for this connection.
|
int |
getSoTimeout() |
java.lang.String |
getStatusCodeReply() |
java.lang.Object |
getUnflushedObject() |
java.util.List<java.lang.Object> |
getUnflushedObjectMultiBulkReply()
Deprecated.
Use
getUnflushedObject(). |
protected java.util.Map<java.lang.String,java.lang.Object> |
hello(byte[]... args) |
protected void |
initializeFromClientConfig(JedisClientConfig config) |
protected void |
initPushConsumers(JedisClientConfig config) |
boolean |
isBroken() |
boolean |
isConnected() |
protected boolean |
isTokenBasedAuthenticationEnabled() |
boolean |
ping() |
protected java.lang.Object |
protocolRead(RedisInputStream is,
PushConsumerChain consumer) |
protected void |
protocolReadPushes(RedisInputStream is,
PushConsumerChain consumer) |
protected java.lang.Object |
readProtocolWithCheckingBroken() |
protected void |
readPushesWithCheckingBroken() |
java.lang.String |
reAuthenticate() |
void |
rollbackTimeout() |
java.lang.String |
select(int index) |
void |
sendCommand(CommandArguments args) |
void |
sendCommand(ProtocolCommand cmd) |
void |
sendCommand(ProtocolCommand cmd,
byte[]... args) |
void |
sendCommand(ProtocolCommand cmd,
Rawable keyword) |
void |
sendCommand(ProtocolCommand cmd,
java.lang.String... args) |
void |
setBroken() |
void |
setCredentials(RedisCredentials credentials) |
void |
setHandlingPool(ConnectionPool pool) |
void |
setSoTimeout(int soTimeout) |
void |
setTimeoutInfinite() |
java.lang.String |
toIdentityString() |
java.lang.String |
toString() |
protected RedisProtocol protocol
Set after the handshake completes. Holds the protocol the connection is actually speaking with the server.
null – No protocol established yet (handshake has not run).RESP2 – RESP2 established (either explicitly requested, fallback from
auto-negotiation, or assumed default when no protocol was requested and
auto-negotiation was disabled).RESP3 – RESP3 established.protected java.lang.String server
protected java.lang.String version
public Connection()
public Connection(java.lang.String host,
int port)
public Connection(HostAndPort hostAndPort)
public Connection(HostAndPort hostAndPort, JedisClientConfig clientConfig)
public Connection(JedisSocketFactory socketFactory)
public Connection(JedisSocketFactory socketFactory, JedisClientConfig clientConfig)
protected Connection(Connection.Builder builder)
public static Connection.Builder builder()
protected void initPushConsumers(JedisClientConfig config)
public java.lang.String toString()
toString in class java.lang.Object@Experimental public java.lang.String toIdentityString()
public final RedisProtocol getRedisProtocol()
null if no protocol has been established yet (handshake has not run);
RedisProtocol.RESP2 or RedisProtocol.RESP3 once the handshake
has completed.public final void setHandlingPool(ConnectionPool pool)
public final HostAndPort getHostAndPort()
public int getSoTimeout()
public void setSoTimeout(int soTimeout)
public void setTimeoutInfinite()
public void rollbackTimeout()
public java.lang.Object executeCommand(ProtocolCommand cmd)
public java.lang.Object executeCommand(CommandArguments args)
public <T> T executeCommand(CommandObject<T> commandObject)
public void sendCommand(ProtocolCommand cmd)
public void sendCommand(ProtocolCommand cmd, Rawable keyword)
public void sendCommand(ProtocolCommand cmd, java.lang.String... args)
public void sendCommand(ProtocolCommand cmd, byte[]... args)
public void sendCommand(CommandArguments args)
public void connect()
throws JedisConnectionException
JedisConnectionExceptionpublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic void disconnect()
public void forceDisconnect()
throws java.io.IOException
java.io.IOExceptionpublic boolean isConnected()
public boolean isBroken()
public void setBroken()
public java.lang.String getStatusCodeReply()
public java.lang.String getBulkReply()
public byte[] getBinaryBulkReply()
public java.lang.Long getIntegerReply()
public java.util.List<java.lang.String> getMultiBulkReply()
public java.util.List<byte[]> getBinaryMultiBulkReply()
@Deprecated public java.util.List<java.lang.Object> getUnflushedObjectMultiBulkReply()
getUnflushedObject().public java.lang.Object getUnflushedObject()
public java.util.List<java.lang.Object> getObjectMultiBulkReply()
public java.util.List<java.lang.Long> getIntegerMultiBulkReply()
public java.lang.Object getOne()
protected void flush()
@Experimental protected java.lang.Object protocolRead(RedisInputStream is, PushConsumerChain consumer)
@Experimental protected void protocolReadPushes(RedisInputStream is, PushConsumerChain consumer)
protected java.lang.Object readProtocolWithCheckingBroken()
protected void readPushesWithCheckingBroken()
public java.util.List<java.lang.Object> getMany(int count)
protected void initializeFromClientConfig(JedisClientConfig config)
public void setCredentials(RedisCredentials credentials)
public java.lang.String reAuthenticate()
protected java.util.Map<java.lang.String,java.lang.Object> hello(byte[]... args)
protected byte[] encodeToBytes(char[] chars)
public java.lang.String select(int index)
public boolean ping()
protected boolean isTokenBasedAuthenticationEnabled()
protected AuthXManager getAuthXManager()
@Internal protected void addPushConsumer(PushConsumer consumer)
Copyright © 2026. All rights reserved.