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:
Yaourt
2010-11-08 15:57:43 +01:00
parent e8704296fd
commit dd6874aa7a
7 changed files with 32 additions and 28 deletions

View File

@@ -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);
}
/**

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}
/**

View File

@@ -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);

View File

@@ -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);
}