Hashes hkeys and hvals refactored to return a set instead of a list.
It looks like the order is not guaranted, so a set seems much adapted than a list.
This commit is contained in:
@@ -829,10 +829,11 @@ public class BinaryJedis implements BinaryJedisCommands {
|
||||
* @param key
|
||||
* @return All the fields names contained into a hash.
|
||||
*/
|
||||
public List<byte[]> hkeys(final byte[] key) {
|
||||
public Set<byte[]> hkeys(final byte[] key) {
|
||||
checkIsInMulti();
|
||||
client.hkeys(key);
|
||||
return client.getBinaryMultiBulkReply();
|
||||
final List<byte[]> lresult = client.getBinaryMultiBulkReply();
|
||||
return new HashSet<byte[]>(lresult);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -843,10 +844,11 @@ public class BinaryJedis implements BinaryJedisCommands {
|
||||
* @param key
|
||||
* @return All the fields values contained into a hash.
|
||||
*/
|
||||
public List<byte[]> hvals(final byte[] key) {
|
||||
public Set<byte[]> hvals(final byte[] key) {
|
||||
checkIsInMulti();
|
||||
client.hvals(key);
|
||||
return client.getBinaryMultiBulkReply();
|
||||
final List<byte[]> lresult = client.getBinaryMultiBulkReply();
|
||||
return new HashSet<byte[]>(lresult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,9 +60,9 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Integer hlen(byte[] key);
|
||||
|
||||
List<byte[]> hkeys(byte[] key);
|
||||
Set<byte[]> hkeys(byte[] key);
|
||||
|
||||
List<byte[]> hvals(byte[] key);
|
||||
Set<byte[]> hvals(byte[] key);
|
||||
|
||||
Map<byte[], byte[]> hgetAll(byte[] key);
|
||||
|
||||
|
||||
@@ -164,12 +164,12 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo> implement
|
||||
return j.hlen(key);
|
||||
}
|
||||
|
||||
public List<byte[]> hkeys(byte[] key) {
|
||||
public Set<byte[]> hkeys(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hkeys(key);
|
||||
}
|
||||
|
||||
public List<byte[]> hvals(byte[] key) {
|
||||
public Set<byte[]> hvals(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hvals(key);
|
||||
}
|
||||
|
||||
@@ -758,10 +758,11 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
* @param key
|
||||
* @return All the fields names contained into a hash.
|
||||
*/
|
||||
public List<String> hkeys(final String key) {
|
||||
public Set<String> hkeys(final String key) {
|
||||
checkIsInMulti();
|
||||
client.hkeys(key);
|
||||
return client.getMultiBulkReply();
|
||||
final List<String> lresult = client.getMultiBulkReply();
|
||||
return new HashSet<String>(lresult);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -772,10 +773,11 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
* @param key
|
||||
* @return All the fields values contained into a hash.
|
||||
*/
|
||||
public List<String> hvals(final String key) {
|
||||
public Set<String> hvals(final String key) {
|
||||
checkIsInMulti();
|
||||
client.hvals(key);
|
||||
return client.getMultiBulkReply();
|
||||
final List<String> lresult = client.getMultiBulkReply();
|
||||
return new HashSet<String>(lresult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,9 +58,9 @@ public interface JedisCommands {
|
||||
|
||||
Integer hlen(String key);
|
||||
|
||||
List<String> hkeys(String key);
|
||||
Set<String> hkeys(String key);
|
||||
|
||||
List<String> hvals(String key);
|
||||
Set<String> hvals(String key);
|
||||
|
||||
Map<String, String> hgetAll(String key);
|
||||
|
||||
|
||||
@@ -150,12 +150,12 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.hlen(key);
|
||||
}
|
||||
|
||||
public List<String> hkeys(String key) {
|
||||
public Set<String> hkeys(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hkeys(key);
|
||||
}
|
||||
|
||||
public List<String> hvals(String key) {
|
||||
public Set<String> hvals(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hvals(key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user