changing default constructor to use default host and port (localhost)
This commit is contained in:
@@ -1,22 +1,26 @@
|
|||||||
package redis.clients.jedis;
|
package redis.clients.jedis;
|
||||||
|
|
||||||
import redis.clients.jedis.Protocol.Command;
|
import static redis.clients.jedis.Protocol.toByteArray;
|
||||||
import redis.clients.jedis.Protocol.Keyword;
|
import static redis.clients.jedis.Protocol.Command.*;
|
||||||
import redis.clients.util.SafeEncoder;
|
import static redis.clients.jedis.Protocol.Keyword.ENCODING;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.IDLETIME;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.LEN;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.LIMIT;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.NO;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.ONE;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.REFCOUNT;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.RESET;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.STORE;
|
||||||
|
import static redis.clients.jedis.Protocol.Keyword.WITHSCORES;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import static redis.clients.jedis.Protocol.Command.*;
|
import redis.clients.jedis.Protocol.Command;
|
||||||
import static redis.clients.jedis.Protocol.Command.EXISTS;
|
import redis.clients.jedis.Protocol.Keyword;
|
||||||
import static redis.clients.jedis.Protocol.Command.PSUBSCRIBE;
|
import redis.clients.util.SafeEncoder;
|
||||||
import static redis.clients.jedis.Protocol.Command.PUNSUBSCRIBE;
|
|
||||||
import static redis.clients.jedis.Protocol.Command.SUBSCRIBE;
|
|
||||||
import static redis.clients.jedis.Protocol.Command.UNSUBSCRIBE;
|
|
||||||
import static redis.clients.jedis.Protocol.Keyword.*;
|
|
||||||
import static redis.clients.jedis.Protocol.toByteArray;
|
|
||||||
|
|
||||||
public class BinaryClient extends Connection {
|
public class BinaryClient extends Connection {
|
||||||
public enum LIST_POSITION {
|
public enum LIST_POSITION {
|
||||||
@@ -44,6 +48,10 @@ public class BinaryClient extends Connection {
|
|||||||
return isInWatch;
|
return isInWatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BinaryClient() {
|
||||||
|
this(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
public BinaryClient(final String host) {
|
public BinaryClient(final String host) {
|
||||||
super(host);
|
super(host);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
|||||||
protected Transaction transaction = null;
|
protected Transaction transaction = null;
|
||||||
protected Pipeline pipeline = null;
|
protected Pipeline pipeline = null;
|
||||||
|
|
||||||
|
public BinaryJedis() {
|
||||||
|
this(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
public BinaryJedis(final String host) {
|
public BinaryJedis(final String host) {
|
||||||
URI uri = URI.create(host);
|
URI uri = URI.create(host);
|
||||||
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
|
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import java.util.Map.Entry;
|
|||||||
import redis.clients.util.SafeEncoder;
|
import redis.clients.util.SafeEncoder;
|
||||||
|
|
||||||
public class Client extends BinaryClient implements Commands {
|
public class Client extends BinaryClient implements Commands {
|
||||||
|
|
||||||
|
public Client() {
|
||||||
|
this(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
public Client(final String host) {
|
public Client(final String host) {
|
||||||
super(host);
|
super(host);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,27 @@ import redis.clients.util.RedisOutputStream;
|
|||||||
import redis.clients.util.SafeEncoder;
|
import redis.clients.util.SafeEncoder;
|
||||||
|
|
||||||
public class Connection implements Closeable {
|
public class Connection implements Closeable {
|
||||||
|
|
||||||
private String host;
|
private String host;
|
||||||
private int port = Protocol.DEFAULT_PORT;
|
private int port = Protocol.DEFAULT_PORT;
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
private RedisOutputStream outputStream;
|
private RedisOutputStream outputStream;
|
||||||
private RedisInputStream inputStream;
|
private RedisInputStream inputStream;
|
||||||
private int timeout = Protocol.DEFAULT_TIMEOUT;
|
private int timeout = Protocol.DEFAULT_TIMEOUT;
|
||||||
|
|
||||||
private boolean broken = false;
|
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() {
|
public Socket getSocket() {
|
||||||
return socket;
|
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) {
|
protected Connection sendCommand(final Command cmd, final String... args) {
|
||||||
final byte[][] bargs = new byte[args.length][];
|
final byte[][] bargs = new byte[args.length][];
|
||||||
for (int i = 0; i < args.length; i++) {
|
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() {
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
@@ -119,10 +121,6 @@ public class Connection implements Closeable {
|
|||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Connection() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void connect() {
|
public void connect() {
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -22,12 +22,8 @@ public class Jedis extends BinaryJedis implements JedisCommands,
|
|||||||
|
|
||||||
protected Pool<Jedis> dataSource = null;
|
protected Pool<Jedis> dataSource = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* CDI eyes only
|
|
||||||
* @deprecated CDI eyes only
|
|
||||||
*/
|
|
||||||
public Jedis() {
|
public Jedis() {
|
||||||
super("localhost");
|
super(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jedis(final String host) {
|
public Jedis(final String host) {
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ import redis.clients.util.Pool;
|
|||||||
|
|
||||||
public class JedisPool extends Pool<Jedis> {
|
public class JedisPool extends Pool<Jedis> {
|
||||||
|
|
||||||
/**
|
public JedisPool() {
|
||||||
* CDI eyes only
|
this(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
|
||||||
* @deprecated CDI eyes only
|
}
|
||||||
*/
|
|
||||||
public JedisPool() {}
|
|
||||||
|
|
||||||
public JedisPool(final GenericObjectPoolConfig poolConfig, final String host) {
|
public JedisPool(final GenericObjectPoolConfig poolConfig, final String host) {
|
||||||
this(poolConfig, host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT,
|
this(poolConfig, host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public final class Protocol {
|
|||||||
private static final String ASK_RESPONSE = "ASK";
|
private static final String ASK_RESPONSE = "ASK";
|
||||||
private static final String MOVED_RESPONSE = "MOVED";
|
private static final String MOVED_RESPONSE = "MOVED";
|
||||||
private static final String CLUSTERDOWN_RESPONSE = "CLUSTERDOWN";
|
private static final String CLUSTERDOWN_RESPONSE = "CLUSTERDOWN";
|
||||||
|
public static final String DEFAULT_HOST = "localhost";
|
||||||
public static final int DEFAULT_PORT = 6379;
|
public static final int DEFAULT_PORT = 6379;
|
||||||
public static final int DEFAULT_SENTINEL_PORT = 26379;
|
public static final int DEFAULT_SENTINEL_PORT = 26379;
|
||||||
public static final int DEFAULT_TIMEOUT = 2000;
|
public static final int DEFAULT_TIMEOUT = 2000;
|
||||||
|
|||||||
Reference in New Issue
Block a user