exists, sismember and hexists return Boolean instead of long
This commit is contained in:
@@ -91,12 +91,12 @@ public class BinaryJedis implements BinaryJedisCommands {
|
||||
* Time complexity: O(1)
|
||||
*
|
||||
* @param key
|
||||
* @return Integer reply, "0" if the key exists, otherwise "1"
|
||||
* @return Integer reply, "1" if the key exists, otherwise "0"
|
||||
*/
|
||||
public Long exists(final byte[] key) {
|
||||
public Boolean exists(final byte[] key) {
|
||||
checkIsInMulti();
|
||||
client.exists(key);
|
||||
return client.getIntegerReply();
|
||||
return client.getIntegerReply() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -784,10 +784,10 @@ public class BinaryJedis implements BinaryJedisCommands {
|
||||
* @return Return 1 if the hash stored at key contains the specified field.
|
||||
* Return 0 if the key is not found or the field is not present.
|
||||
*/
|
||||
public Long hexists(final byte[] key, final byte[] field) {
|
||||
public Boolean hexists(final byte[] key, final byte[] field) {
|
||||
checkIsInMulti();
|
||||
client.hexists(key, field);
|
||||
return client.getIntegerReply();
|
||||
return client.getIntegerReply() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1280,10 +1280,10 @@ public class BinaryJedis implements BinaryJedisCommands {
|
||||
* set 0 if the element is not a member of the set OR if the key
|
||||
* does not exist
|
||||
*/
|
||||
public Long sismember(final byte[] key, final byte[] member) {
|
||||
public Boolean sismember(final byte[] key, final byte[] member) {
|
||||
checkIsInMulti();
|
||||
client.sismember(key, member);
|
||||
return client.getIntegerReply();
|
||||
return client.getIntegerReply() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface BinaryJedisCommands {
|
||||
|
||||
byte[] get(byte[] key);
|
||||
|
||||
Long exists(byte[] key);
|
||||
Boolean exists(byte[] key);
|
||||
|
||||
String type(byte[] key);
|
||||
|
||||
@@ -55,7 +55,7 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Long hincrBy(byte[] key, byte[] field, int value);
|
||||
|
||||
Long hexists(byte[] key, byte[] field);
|
||||
Boolean hexists(byte[] key, byte[] field);
|
||||
|
||||
Long hdel(byte[] key, byte[] field);
|
||||
|
||||
@@ -97,7 +97,7 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Long scard(byte[] key);
|
||||
|
||||
Long sismember(byte[] key, byte[] member);
|
||||
Boolean sismember(byte[] key, byte[] member);
|
||||
|
||||
byte[] srandmember(byte[] key);
|
||||
|
||||
@@ -131,29 +131,17 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Set<byte[]> zrangeByScore(byte[] key, double min, double max);
|
||||
|
||||
Set<byte[]> zrangeByScore(
|
||||
byte[] key,
|
||||
double min,
|
||||
double max,
|
||||
int offset,
|
||||
int count);
|
||||
Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset,
|
||||
int count);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(
|
||||
byte[] key,
|
||||
double min,
|
||||
double max,
|
||||
int offset,
|
||||
int count);
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max,
|
||||
int offset, int count);
|
||||
|
||||
Long zremrangeByRank(byte[] key, int start, int end);
|
||||
|
||||
Long zremrangeByScore(byte[] key, double start, double end);
|
||||
|
||||
Long linsert(
|
||||
byte[] key,
|
||||
LIST_POSITION where,
|
||||
byte[] pivot,
|
||||
byte[] value);
|
||||
Long linsert(byte[] key, LIST_POSITION where, byte[] pivot, byte[] value);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
|
||||
return j.get(key);
|
||||
}
|
||||
|
||||
public Long exists(byte[] key) {
|
||||
public Boolean exists(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.exists(key);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
|
||||
return j.hincrBy(key, field, value);
|
||||
}
|
||||
|
||||
public Long hexists(byte[] key, byte[] field) {
|
||||
public Boolean hexists(byte[] key, byte[] field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hexists(key, field);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
|
||||
return j.scard(key);
|
||||
}
|
||||
|
||||
public Long sismember(byte[] key, byte[] member) {
|
||||
public Boolean sismember(byte[] key, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sismember(key, member);
|
||||
}
|
||||
|
||||
@@ -78,19 +78,19 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the specified key exists. The command returns "0" if the key
|
||||
* Test if the specified key exists. The command returns "1" if the key
|
||||
* exists, otherwise "1" is returned. Note that even keys set with an empty
|
||||
* string as value will return "1".
|
||||
* string as value will return "0".
|
||||
*
|
||||
* Time complexity: O(1)
|
||||
*
|
||||
* @param key
|
||||
* @return Integer reply, "0" if the key exists, otherwise "1"
|
||||
*/
|
||||
public Long exists(final String key) {
|
||||
public Boolean exists(final String key) {
|
||||
runChecks();
|
||||
client.exists(key);
|
||||
return client.getIntegerReply();
|
||||
return client.getIntegerReply() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -782,10 +782,10 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
* @return Return 1 if the hash stored at key contains the specified field.
|
||||
* Return 0 if the key is not found or the field is not present.
|
||||
*/
|
||||
public Long hexists(final String key, final String field) {
|
||||
public Boolean hexists(final String key, final String field) {
|
||||
runChecks();
|
||||
client.hexists(key, field);
|
||||
return client.getIntegerReply();
|
||||
return client.getIntegerReply() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1278,10 +1278,10 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
* set 0 if the element is not a member of the set OR if the key
|
||||
* does not exist
|
||||
*/
|
||||
public Long sismember(final String key, final String member) {
|
||||
public Boolean sismember(final String key, final String member) {
|
||||
runChecks();
|
||||
client.sismember(key, member);
|
||||
return client.getIntegerReply();
|
||||
return client.getIntegerReply() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface JedisCommands {
|
||||
|
||||
String get(String key);
|
||||
|
||||
Long exists(String key);
|
||||
Boolean exists(String key);
|
||||
|
||||
String type(String key);
|
||||
|
||||
@@ -53,7 +53,7 @@ public interface JedisCommands {
|
||||
|
||||
Long hincrBy(String key, String field, int value);
|
||||
|
||||
Long hexists(String key, String field);
|
||||
Boolean hexists(String key, String field);
|
||||
|
||||
Long hdel(String key, String field);
|
||||
|
||||
@@ -95,7 +95,7 @@ public interface JedisCommands {
|
||||
|
||||
Long scard(String key);
|
||||
|
||||
Long sismember(String key, String member);
|
||||
Boolean sismember(String key, String member);
|
||||
|
||||
String srandmember(String key);
|
||||
|
||||
@@ -129,18 +129,18 @@ public interface JedisCommands {
|
||||
|
||||
Set<String> zrangeByScore(String key, double min, double max);
|
||||
|
||||
Set<String> zrangeByScore(String key, double min, double max,
|
||||
int offset, int count);
|
||||
Set<String> zrangeByScore(String key, double min, double max, int offset,
|
||||
int count);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(String key, double min, double max);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(String key, double min,
|
||||
double max, int offset, int count);
|
||||
Set<Tuple> zrangeByScoreWithScores(String key, double min, double max,
|
||||
int offset, int count);
|
||||
|
||||
Long zremrangeByRank(String key, int start, int end);
|
||||
|
||||
Long zremrangeByScore(String key, double start, double end);
|
||||
|
||||
Long linsert(String key, Client.LIST_POSITION where, String pivot,
|
||||
String value);
|
||||
String value);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect() throws IOException {
|
||||
public void disconnect() throws IOException {
|
||||
for (Jedis jedis : getAllShards()) {
|
||||
jedis.quit();
|
||||
jedis.disconnect();
|
||||
@@ -46,7 +46,7 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.get(key);
|
||||
}
|
||||
|
||||
public Long exists(String key) {
|
||||
public Boolean exists(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.exists(key);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.hincrBy(key, field, value);
|
||||
}
|
||||
|
||||
public Long hexists(String key, String field) {
|
||||
public Boolean hexists(String key, String field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hexists(key, field);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.scard(key);
|
||||
}
|
||||
|
||||
public Long sismember(String key, String member) {
|
||||
public Boolean sismember(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sismember(key, member);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user