add getDB() which return the db number we are connected to
This commit is contained in:
@@ -27,9 +27,11 @@ public class BinaryClient extends Connection {
|
||||
}
|
||||
|
||||
private boolean isInMulti;
|
||||
|
||||
|
||||
private String password;
|
||||
|
||||
private long db;
|
||||
|
||||
public boolean isInMulti() {
|
||||
return isInMulti;
|
||||
}
|
||||
@@ -41,11 +43,11 @@ public class BinaryClient extends Connection {
|
||||
public BinaryClient(final String host, final int port) {
|
||||
super(host, port);
|
||||
}
|
||||
|
||||
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void connect() {
|
||||
if (!isConnected()) {
|
||||
@@ -70,6 +72,7 @@ public class BinaryClient extends Connection {
|
||||
}
|
||||
|
||||
public void quit() {
|
||||
db = 0;
|
||||
sendCommand(QUIT);
|
||||
}
|
||||
|
||||
@@ -122,6 +125,7 @@ public class BinaryClient extends Connection {
|
||||
}
|
||||
|
||||
public void select(final int index) {
|
||||
db = index;
|
||||
sendCommand(SELECT, toByteArray(index));
|
||||
}
|
||||
|
||||
@@ -455,7 +459,7 @@ public class BinaryClient extends Connection {
|
||||
}
|
||||
|
||||
public void auth(final String password) {
|
||||
setPassword(password);
|
||||
setPassword(password);
|
||||
sendCommand(AUTH, password);
|
||||
}
|
||||
|
||||
@@ -495,6 +499,7 @@ public class BinaryClient extends Connection {
|
||||
final double max) {
|
||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max));
|
||||
}
|
||||
|
||||
public void zrevrangeByScore(final byte[] key, final double max,
|
||||
final double min) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min));
|
||||
@@ -504,6 +509,7 @@ public class BinaryClient extends Connection {
|
||||
final byte[] max) {
|
||||
sendCommand(ZRANGEBYSCORE, key, min, max);
|
||||
}
|
||||
|
||||
public void zrevrangeByScore(final byte[] key, final byte[] max,
|
||||
final byte[] min) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, max, min);
|
||||
@@ -514,6 +520,7 @@ public class BinaryClient extends Connection {
|
||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max),
|
||||
LIMIT.raw, toByteArray(offset), toByteArray(count));
|
||||
}
|
||||
|
||||
public void zrevrangeByScore(final byte[] key, final double max,
|
||||
final double min, final int offset, int count) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
||||
@@ -525,6 +532,7 @@ public class BinaryClient extends Connection {
|
||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max),
|
||||
WITHSCORES.raw);
|
||||
}
|
||||
|
||||
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
|
||||
final double min) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
||||
@@ -537,6 +545,7 @@ public class BinaryClient extends Connection {
|
||||
LIMIT.raw, toByteArray(offset), toByteArray(count),
|
||||
WITHSCORES.raw);
|
||||
}
|
||||
|
||||
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
|
||||
final double min, final int offset, final int count) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
||||
@@ -692,6 +701,16 @@ public class BinaryClient extends Connection {
|
||||
}
|
||||
|
||||
public void getrange(byte[] key, long startOffset, long endOffset) {
|
||||
sendCommand(GETRANGE, key, toByteArray(startOffset), toByteArray(endOffset));
|
||||
sendCommand(GETRANGE, key, toByteArray(startOffset),
|
||||
toByteArray(endOffset));
|
||||
}
|
||||
|
||||
public Long getDB() {
|
||||
return db;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
db = 0;
|
||||
super.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2994,4 +2994,8 @@ public class BinaryJedis implements BinaryJedisCommands {
|
||||
jedisPubSub.proceedWithPatterns(client, patterns);
|
||||
client.rollbackTimeout();
|
||||
}
|
||||
|
||||
public Long getDB() {
|
||||
return client.getDB();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user