Class RedisConnectionAbstract
java.lang.Object
com.blackrook.redis.RedisConnectionAbstract
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
RedisConnection, RedisDebugConnection, RedisMonitorConnection, RedisPubSubConnection, RedisServerConnection, RedisUserConnection
A single connection to a Redis server.
- Author:
- Matthew Tropiano
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RESPReaderThe input wrapper.protected RESPWriterThe output wrapper. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an open connection to localhost, port 6379, the default Redis port.Creates an open connection.RedisConnectionAbstract(String host, int port) Creates an open connection.RedisConnectionAbstract(String host, int port, String password) Creates an open connection. -
Method Summary
-
Field Details
-
reader
The input wrapper. -
writer
The output wrapper.
-
-
Constructor Details
-
RedisConnectionAbstract
Creates an open connection to localhost, port 6379, the default Redis port.- Throws:
IOException- if an I/O error occurs when creating the socket.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.
-
RedisConnectionAbstract
Creates an open connection.- Parameters:
host- the server hostname or address.port- the server connection port.- Throws:
IOException- if an I/O error occurs when creating the socket.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.
-
RedisConnectionAbstract
Creates an open connection.- Parameters:
host- the server hostname or address.port- the server connection port.password- the server database password.- Throws:
IOException- if an I/O error occurs when creating the socket.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.RedisException- if the password in the server information is incorrect.
-
RedisConnectionAbstract
Creates an open connection.- Parameters:
info- theRedisInfoclass detailing a connection.- Throws:
IOException- if an I/O error occurs when creating the socket.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.RedisException- if the password in the server information is incorrect.
-
-
Method Details
-
reconnect
Reconnects to a server.- Throws:
IOException- if an I/O error occurs when creating the socket or the socket is already open.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.RedisException- if the password in the server information is incorrect.
-
disconnect
protected void disconnect() -
isBound
public boolean isBound()Checks if this connection is successfully bound to an address.- Returns:
- true if so, false if not.
-
isConnected
public boolean isConnected()Checks if this connection is connected to an endpoint.- Returns:
- true if so, false if not.
-
isClosed
public boolean isClosed()Checks if this connection is closed.- Returns:
- true if so, false if not.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-