add watch on several keys, and discard status return
This commit is contained in:
@@ -396,8 +396,8 @@ public class BinaryClient extends Connection {
|
||||
isInMulti = false;
|
||||
}
|
||||
|
||||
public void watch(final byte[] key) {
|
||||
sendCommand(WATCH, key);
|
||||
public void watch(final byte[]... keys) {
|
||||
sendCommand(WATCH, keys);
|
||||
}
|
||||
|
||||
public void unwatch() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Map;
|
||||
|
||||
public class BinaryTransaction {
|
||||
protected Client client = null;
|
||||
protected boolean inTransaction = true;
|
||||
|
||||
public BinaryTransaction() {
|
||||
}
|
||||
@@ -424,7 +425,9 @@ public class BinaryTransaction {
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public void discard() {
|
||||
public String discard() {
|
||||
client.discard();
|
||||
inTransaction = false;
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
}
|
||||
@@ -360,8 +360,12 @@ public class Client extends BinaryClient {
|
||||
zscore(SafeEncoder.encode(key), SafeEncoder.encode(member));
|
||||
}
|
||||
|
||||
public void watch(final String key) {
|
||||
watch(SafeEncoder.encode(key));
|
||||
public void watch(final String... keys) {
|
||||
final byte[][] bargs = new byte[keys.length][];
|
||||
for (int i = 0; i < bargs.length; i++) {
|
||||
bargs[i] = SafeEncoder.encode(keys[i]);
|
||||
}
|
||||
watch(bargs);
|
||||
}
|
||||
|
||||
public void sort(final String key) {
|
||||
|
||||
@@ -1669,8 +1669,8 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
public String watch(final String key) {
|
||||
client.watch(key);
|
||||
public String watch(final String... keys) {
|
||||
client.watch(keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
|
||||
@Test
|
||||
public void watch() throws UnknownHostException, IOException {
|
||||
jedis.watch("mykey");
|
||||
jedis.watch("mykey", "somekey");
|
||||
Transaction t = jedis.multi();
|
||||
|
||||
nj.connect();
|
||||
@@ -197,4 +197,11 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
jedis.multi();
|
||||
jedis.ping();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void discard() {
|
||||
Transaction t = jedis.multi();
|
||||
String status = t.discard();
|
||||
assertEquals("OK", status);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user