changing default constructor to use default host and port (localhost)

This commit is contained in:
Nykolas Lima
2014-09-27 13:37:42 -03:00
parent f065b80ab0
commit 833065b670
7 changed files with 47 additions and 37 deletions

View File

@@ -16,14 +16,27 @@ import redis.clients.util.RedisOutputStream;
import redis.clients.util.SafeEncoder;
public class Connection implements Closeable {
private String host;
private int port = Protocol.DEFAULT_PORT;
private Socket socket;
private RedisOutputStream outputStream;
private RedisInputStream inputStream;
private int timeout = Protocol.DEFAULT_TIMEOUT;
private boolean broken = false;
public Connection() {
this(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
}
public Connection(final String host) {
this.host = host;
}
public Connection(final String host, final int port) {
this.host = host;
this.port = port;
}
public Socket getSocket() {
return socket;
@@ -60,11 +73,6 @@ public class Connection implements Closeable {
}
}
public Connection(final String host) {
super();
this.host = host;
}
protected Connection sendCommand(final Command cmd, final String... args) {
final byte[][] bargs = new byte[args.length][];
for (int i = 0; i < args.length; i++) {
@@ -97,12 +105,6 @@ public class Connection implements Closeable {
}
}
public Connection(final String host, final int port) {
super();
this.host = host;
this.port = port;
}
public String getHost() {
return host;
}
@@ -119,10 +121,6 @@ public class Connection implements Closeable {
this.port = port;
}
public Connection() {
}
public void connect() {
if (!isConnected()) {
try {