added variadic versions of lpush/rpush(x) functions

This commit is contained in:
samhendley
2013-01-10 02:39:48 -05:00
parent 6b5fccdc0a
commit 258ac300fc
12 changed files with 42 additions and 52 deletions

View File

@@ -677,16 +677,16 @@ public class BinaryClient extends Connection {
sendCommand(SYNC); sendCommand(SYNC);
} }
public void lpushx(final byte[] key, final byte[] string) { public void lpushx(final byte[] key, final byte[]... string) {
sendCommand(LPUSHX, key, string); sendCommand(LPUSHX, joinParameters(key, string));
} }
public void persist(final byte[] key) { public void persist(final byte[] key) {
sendCommand(PERSIST, key); sendCommand(PERSIST, key);
} }
public void rpushx(final byte[] key, final byte[] string) { public void rpushx(final byte[] key, final byte[]... string) {
sendCommand(RPUSHX, key, string); sendCommand(RPUSHX, joinParameters(key, string));
} }
public void echo(final byte[] string) { public void echo(final byte[] string) {

View File

@@ -2979,7 +2979,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
client.sync(); client.sync();
} }
public Long lpushx(final byte[] key, final byte[] string) { public Long lpushx(final byte[] key, final byte[]... string) {
client.lpushx(key, string); client.lpushx(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }
@@ -2999,7 +2999,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Long rpushx(final byte[] key, final byte[] string) { public Long rpushx(final byte[] key, final byte[]... string) {
client.rpushx(key, string); client.rpushx(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }

View File

@@ -196,9 +196,9 @@ public interface BinaryJedisCommands {
Long linsert(byte[] key, Client.LIST_POSITION where, byte[] pivot, Long linsert(byte[] key, Client.LIST_POSITION where, byte[] pivot,
byte[] value); byte[] value);
Long lpushx(byte[] key, byte[] arg); Long lpushx(byte[] key, byte[]... arg);
Long rpushx(byte[] key, byte[] arg); Long rpushx(byte[] key, byte[]... arg);
List<byte[]> blpop(byte[] arg); List<byte[]> blpop(byte[] arg);

View File

@@ -73,9 +73,9 @@ public interface BinaryRedisPipeline {
Response<byte[]> lpop(byte[] key); Response<byte[]> lpop(byte[] key);
Response<Long> lpush(byte[] key, byte[] string); Response<Long> lpush(byte[] key, byte[]... string);
Response<Long> lpushx(byte[] key, byte[] bytes); Response<Long> lpushx(byte[] key, byte[]... bytes);
Response<List<byte[]>> lrange(byte[] key, long start, long end); Response<List<byte[]>> lrange(byte[] key, long start, long end);
@@ -91,11 +91,11 @@ public interface BinaryRedisPipeline {
Response<byte[]> rpop(byte[] key); Response<byte[]> rpop(byte[] key);
Response<Long> rpush(byte[] key, byte[] string); Response<Long> rpush(byte[] key, byte[]... string);
Response<Long> rpushx(byte[] key, byte[] string); Response<Long> rpushx(byte[] key, byte[]... string);
Response<Long> sadd(byte[] key, byte[] member); Response<Long> sadd(byte[] key, byte[]... member);
Response<Long> scard(byte[] key); Response<Long> scard(byte[] key);

View File

@@ -201,7 +201,7 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
return j.strlen(key); return j.strlen(key);
} }
public Long lpushx(byte[] key, byte[] string) { public Long lpushx(byte[] key, byte[]... string) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.lpushx(key, string); return j.lpushx(key, string);
} }
@@ -211,7 +211,7 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
return j.persist(key); return j.persist(key);
} }
public Long rpushx(byte[] key, byte[] string) { public Long rpushx(byte[] key, byte[]... string) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.rpushx(key, string); return j.rpushx(key, string);
} }

View File

@@ -564,16 +564,16 @@ public class Client extends BinaryClient implements Commands {
strlen(SafeEncoder.encode(key)); strlen(SafeEncoder.encode(key));
} }
public void lpushx(final String key, final String string) { public void lpushx(final String key, final String... string) {
lpushx(SafeEncoder.encode(key), SafeEncoder.encode(string)); lpushx(SafeEncoder.encode(key), getByteParams(string));
} }
public void persist(final String key) { public void persist(final String key) {
persist(SafeEncoder.encode(key)); persist(SafeEncoder.encode(key));
} }
public void rpushx(final String key, final String string) { public void rpushx(final String key, final String... string) {
rpushx(SafeEncoder.encode(key), SafeEncoder.encode(string)); rpushx(SafeEncoder.encode(key), getByteParams(string));
} }
public void echo(final String string) { public void echo(final String string) {

View File

@@ -251,11 +251,11 @@ public interface Commands {
public void strlen(final String key); public void strlen(final String key);
public void lpushx(final String key, final String string); public void lpushx(final String key, final String... string);
public void persist(final String key); public void persist(final String key);
public void rpushx(final String key, final String string); public void rpushx(final String key, final String... string);
public void echo(final String string); public void echo(final String string);

View File

@@ -2535,7 +2535,7 @@ public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommand
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Long lpushx(final String key, final String string) { public Long lpushx(final String key, final String... string) {
client.lpushx(key, string); client.lpushx(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }
@@ -2555,7 +2555,7 @@ public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommand
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Long rpushx(final String key, final String string) { public Long rpushx(final String key, final String... string) {
client.rpushx(key, string); client.rpushx(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }

View File

@@ -193,9 +193,9 @@ public interface JedisCommands {
Long linsert(String key, Client.LIST_POSITION where, String pivot, Long linsert(String key, Client.LIST_POSITION where, String pivot,
String value); String value);
Long lpushx(String key, String string); Long lpushx(String key, String... string);
Long rpushx(String key, String string); Long rpushx(String key, String... string);
List<String> blpop(String arg); List<String> blpop(String arg);

View File

@@ -305,16 +305,6 @@ abstract class PipelineBase extends Queable implements
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Set<String>> keys(String pattern) {
getClient(pattern).keys(pattern);
return getResponse(BuilderFactory.STRING_SET);
}
public Response<Set<byte[]>> keys(byte[] pattern) {
getClient(pattern).keys(pattern);
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
}
public Response<String> lindex(String key, int index) { public Response<String> lindex(String key, int index) {
getClient(key).lindex(key, index); getClient(key).lindex(key, index);
return getResponse(BuilderFactory.STRING); return getResponse(BuilderFactory.STRING);
@@ -357,22 +347,22 @@ abstract class PipelineBase extends Queable implements
return getResponse(BuilderFactory.BYTE_ARRAY); return getResponse(BuilderFactory.BYTE_ARRAY);
} }
public Response<Long> lpush(String key, String string) { public Response<Long> lpush(String key, String... string) {
getClient(key).lpush(key, string); getClient(key).lpush(key, string);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> lpush(byte[] key, byte[] string) { public Response<Long> lpush(byte[] key, byte[]... string) {
getClient(key).lpush(key, string); getClient(key).lpush(key, string);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> lpushx(String key, String string) { public Response<Long> lpushx(String key, String... string) {
getClient(key).lpushx(key, string); getClient(key).lpushx(key, string);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> lpushx(byte[] key, byte[] bytes) { public Response<Long> lpushx(byte[] key, byte[]... bytes) {
getClient(key).lpushx(key, bytes); getClient(key).lpushx(key, bytes);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
@@ -447,32 +437,32 @@ abstract class PipelineBase extends Queable implements
return getResponse(BuilderFactory.BYTE_ARRAY); return getResponse(BuilderFactory.BYTE_ARRAY);
} }
public Response<Long> rpush(String key, String string) { public Response<Long> rpush(String key, String... string) {
getClient(key).rpush(key, string); getClient(key).rpush(key, string);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> rpush(byte[] key, byte[] string) { public Response<Long> rpush(byte[] key, byte[]... string) {
getClient(key).rpush(key, string); getClient(key).rpush(key, string);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> rpushx(String key, String string) { public Response<Long> rpushx(String key, String... string) {
getClient(key).rpushx(key, string); getClient(key).rpushx(key, string);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> rpushx(byte[] key, byte[] string) { public Response<Long> rpushx(byte[] key, byte[]... string) {
getClient(key).rpushx(key, string); getClient(key).rpushx(key, string);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> sadd(String key, String member) { public Response<Long> sadd(String key, String... member) {
getClient(key).sadd(key, member); getClient(key).sadd(key, member);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> sadd(byte[] key, byte[] member) { public Response<Long> sadd(byte[] key, byte[]... member) {
getClient(key).sadd(key, member); getClient(key).sadd(key, member);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }

View File

@@ -76,9 +76,9 @@ public interface RedisPipeline {
Response<String> lpop(String key); Response<String> lpop(String key);
Response<Long> lpush(String key, String string); Response<Long> lpush(String key, String... string);
Response<Long> lpushx(String key, String string); Response<Long> lpushx(String key, String... string);
Response<List<String>> lrange(String key, long start, long end); Response<List<String>> lrange(String key, long start, long end);
@@ -94,11 +94,11 @@ public interface RedisPipeline {
Response<String> rpop(String key); Response<String> rpop(String key);
Response<Long> rpush(String key, String string); Response<Long> rpush(String key, String... string);
Response<Long> rpushx(String key, String string); Response<Long> rpushx(String key, String... string);
Response<Long> sadd(String key, String member); Response<Long> sadd(String key, String... member);
Response<Long> scard(String key); Response<Long> scard(String key);

View File

@@ -221,7 +221,7 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
return j.lpush(key, strings); return j.lpush(key, strings);
} }
public Long lpushx(String key, String string) { public Long lpushx(String key, String... string) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.lpushx(key, string); return j.lpushx(key, string);
} }
@@ -236,7 +236,7 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
return j.move(key, dbIndex); return j.move(key, dbIndex);
} }
public Long rpushx(String key, String string) { public Long rpushx(String key, String... string) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.rpushx(key, string); return j.rpushx(key, string);
} }