add getDB() which return the db number we are connected to
This commit is contained in:
@@ -30,6 +30,8 @@ public class BinaryClient extends Connection {
|
|||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
private long db;
|
||||||
|
|
||||||
public boolean isInMulti() {
|
public boolean isInMulti() {
|
||||||
return isInMulti;
|
return isInMulti;
|
||||||
}
|
}
|
||||||
@@ -70,6 +72,7 @@ public class BinaryClient extends Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void quit() {
|
public void quit() {
|
||||||
|
db = 0;
|
||||||
sendCommand(QUIT);
|
sendCommand(QUIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +125,7 @@ public class BinaryClient extends Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void select(final int index) {
|
public void select(final int index) {
|
||||||
|
db = index;
|
||||||
sendCommand(SELECT, toByteArray(index));
|
sendCommand(SELECT, toByteArray(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,6 +499,7 @@ public class BinaryClient extends Connection {
|
|||||||
final double max) {
|
final double max) {
|
||||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max));
|
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zrevrangeByScore(final byte[] key, final double max,
|
public void zrevrangeByScore(final byte[] key, final double max,
|
||||||
final double min) {
|
final double min) {
|
||||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min));
|
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min));
|
||||||
@@ -504,6 +509,7 @@ public class BinaryClient extends Connection {
|
|||||||
final byte[] max) {
|
final byte[] max) {
|
||||||
sendCommand(ZRANGEBYSCORE, key, min, max);
|
sendCommand(ZRANGEBYSCORE, key, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zrevrangeByScore(final byte[] key, final byte[] max,
|
public void zrevrangeByScore(final byte[] key, final byte[] max,
|
||||||
final byte[] min) {
|
final byte[] min) {
|
||||||
sendCommand(ZREVRANGEBYSCORE, key, max, min);
|
sendCommand(ZREVRANGEBYSCORE, key, max, min);
|
||||||
@@ -514,6 +520,7 @@ public class BinaryClient extends Connection {
|
|||||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max),
|
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max),
|
||||||
LIMIT.raw, toByteArray(offset), toByteArray(count));
|
LIMIT.raw, toByteArray(offset), toByteArray(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zrevrangeByScore(final byte[] key, final double max,
|
public void zrevrangeByScore(final byte[] key, final double max,
|
||||||
final double min, final int offset, int count) {
|
final double min, final int offset, int count) {
|
||||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
||||||
@@ -525,6 +532,7 @@ public class BinaryClient extends Connection {
|
|||||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max),
|
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max),
|
||||||
WITHSCORES.raw);
|
WITHSCORES.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
|
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
|
||||||
final double min) {
|
final double min) {
|
||||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
||||||
@@ -537,6 +545,7 @@ public class BinaryClient extends Connection {
|
|||||||
LIMIT.raw, toByteArray(offset), toByteArray(count),
|
LIMIT.raw, toByteArray(offset), toByteArray(count),
|
||||||
WITHSCORES.raw);
|
WITHSCORES.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
|
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
|
||||||
final double min, final int offset, final int count) {
|
final double min, final int offset, final int count) {
|
||||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
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) {
|
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);
|
jedisPubSub.proceedWithPatterns(client, patterns);
|
||||||
client.rollbackTimeout();
|
client.rollbackTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getDB() {
|
||||||
|
return client.getDB();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -343,6 +343,13 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
|||||||
assertArrayEquals(bbar, jedis.get(bfoo));
|
assertArrayEquals(bbar, jedis.get(bfoo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDB() {
|
||||||
|
assertEquals(0, jedis.getDB().longValue());
|
||||||
|
jedis.select(1);
|
||||||
|
assertEquals(1, jedis.getDB().longValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void move() {
|
public void move() {
|
||||||
long status = jedis.move("foo", 1);
|
long status = jedis.move("foo", 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user