Package com.blackrook.redis
Class RedisUserConnection
- java.lang.Object
-
- com.blackrook.redis.RedisConnectionAbstract
-
- com.blackrook.redis.RedisUserConnection
-
- All Implemented Interfaces:
AutoCloseable
public class RedisUserConnection extends RedisConnectionAbstract
A connection to Redis that allows completely open submission to Redis. All requests are set via on type of method, and all responses are returned with minimal interpretation.- Author:
- Matthew Tropiano
-
-
Field Summary
-
Fields inherited from class com.blackrook.redis.RedisConnectionAbstract
reader, writer
-
-
Constructor Summary
Constructors Constructor Description RedisUserConnection()
Creates an open connection to localhost, port 6379, the default Redis port.RedisUserConnection(RedisInfo info)
Creates an open connection.RedisUserConnection(String host, int port)
Creates an open connection.RedisUserConnection(String host, int port, String password)
Creates an open connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RedisObject
sendCommandString(String commandString)
Sends a request to a Redis server in the form of a literal command.RedisObject
sendRequest(Object... arguments)
Sends a raw request to a Redis server in the form of a literal command, already separated into tokens.RedisObject
sendRequest(String... arguments)
Sends a request to a Redis server in the form of a literal command, already separated into tokens.-
Methods inherited from class com.blackrook.redis.RedisConnectionAbstract
close, disconnect, isBound, isClosed, isConnected, reconnect
-
-
-
-
Constructor Detail
-
RedisUserConnection
public RedisUserConnection() throws IOException
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.
-
RedisUserConnection
public RedisUserConnection(String host, int port) throws IOException
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.
-
RedisUserConnection
public RedisUserConnection(String host, int port, String password) throws IOException
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.
-
RedisUserConnection
public RedisUserConnection(RedisInfo info) throws IOException
Creates an open connection.- Parameters:
info
- theRedisInfo
class 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 Detail
-
sendCommandString
public RedisObject sendCommandString(String commandString)
Sends a request to a Redis server in the form of a literal command. This command is NOT sent verbatim - it is converted to a raw request before send.- Parameters:
commandString
- the command to send as a full request.- Returns:
- a
RedisObject
representing the response from the server.
-
sendRequest
public RedisObject sendRequest(String... arguments)
Sends a request to a Redis server in the form of a literal command, already separated into tokens. This command is NOT sent verbatim - it is converted to a raw request before send.- Parameters:
arguments
- the list of arguments to send as a full request.- Returns:
- a
RedisObject
representing the response from the server.
-
sendRequest
public RedisObject sendRequest(Object... arguments)
Sends a raw request to a Redis server in the form of a literal command, already separated into tokens. Each object is converted to a String viaString.valueOf(Object)
.- Parameters:
arguments
- the list of arguments to send as a full request.- Returns:
- a
RedisObject
representing the response from the server.
-
-