Variadic commands

This commit is contained in:
ivowiblo
2012-04-18 15:22:43 -04:00
parent e4f7f61d00
commit 8aca0b77f9
10 changed files with 176 additions and 102 deletions

View File

@@ -779,13 +779,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
* <b>Time complexity:</b> O(1)
*
* @param key
* @param field
* @param fields
* @return If the field was present in the hash it is deleted and 1 is
* returned, otherwise 0 is returned and no operation is performed.
*/
public Long hdel(final String key, final String field) {
public Long hdel(final String key, final String... fields) {
checkIsInMulti();
client.hdel(key, field);
client.hdel(key, fields);
return client.getIntegerReply();
}
@@ -861,13 +861,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
* @see Jedis#lpush(String, String)
*
* @param key
* @param string
* @param strings
* @return Integer reply, specifically, the number of elements inside the
* list after the push operation.
*/
public Long rpush(final String key, final String string) {
public Long rpush(final String key, final String... strings) {
checkIsInMulti();
client.rpush(key, string);
client.rpush(key, strings);
return client.getIntegerReply();
}
@@ -882,13 +882,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
* @see Jedis#rpush(String, String)
*
* @param key
* @param string
* @param strings
* @return Integer reply, specifically, the number of elements inside the
* list after the push operation.
*/
public Long lpush(final String key, final String string) {
public Long lpush(final String key, final String... strings) {
checkIsInMulti();
client.lpush(key, string);
client.lpush(key, strings);
return client.getIntegerReply();
}
@@ -1139,13 +1139,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
* Time complexity O(1)
*
* @param key
* @param member
* @param members
* @return Integer reply, specifically: 1 if the new element was added 0 if
* the element was already a member of the set
*/
public Long sadd(final String key, final String member) {
public Long sadd(final String key, final String... members) {
checkIsInMulti();
client.sadd(key, member);
client.sadd(key, members);
return client.getIntegerReply();
}
@@ -1173,13 +1173,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
* Time complexity O(1)
*
* @param key
* @param member
* @param members
* @return Integer reply, specifically: 1 if the new element was removed 0
* if the new element was not a member of the set
*/
public Long srem(final String key, final String member) {
public Long srem(final String key, final String... members) {
checkIsInMulti();
client.srem(key, member);
client.srem(key, members);
return client.getIntegerReply();
}
@@ -1435,6 +1435,12 @@ public class Jedis extends BinaryJedis implements JedisCommands {
client.zadd(key, score, member);
return client.getIntegerReply();
}
public Long zadd(final String key, final Map<Double, String> scoreMembers) {
checkIsInMulti();
client.zadd(key, scoreMembers);
return client.getIntegerReply();
}
public Set<String> zrange(final String key, final int start, final int end) {
checkIsInMulti();
@@ -1454,13 +1460,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
*
*
* @param key
* @param member
* @param members
* @return Integer reply, specifically: 1 if the new element was removed 0
* if the new element was not a member of the set
*/
public Long zrem(final String key, final String member) {
public Long zrem(final String key, final String... members) {
checkIsInMulti();
client.zrem(key, member);
client.zrem(key, members);
return client.getIntegerReply();
}