Skip to content

Commit

Permalink
Merge pull request #2032 from sazzad16/unwatch-multi-pipeline
Browse files Browse the repository at this point in the history
Add missing UNWATCH in Transaction and Pipeline
  • Loading branch information
sazzad16 committed Oct 16, 2019
2 parents 13cfd1e + 251b532 commit fac7ddd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/redis/clients/jedis/MultiKeyPipelineBase.java
Expand Up @@ -307,6 +307,12 @@ public Response<String> watch(byte[]... keys) {
return getResponse(BuilderFactory.STRING);
}

@Override
public Response<String> unwatch() {
client.unwatch();
return getResponse(BuilderFactory.STRING);
}

@Override
public Response<Long> zinterstore(String dstkey, String... sets) {
client.zinterstore(dstkey, sets);
Expand Down
Expand Up @@ -58,6 +58,8 @@ public interface MultiKeyBinaryRedisPipeline {

Response<String> watch(byte[]... keys);

Response<String> unwatch();

Response<Long> zinterstore(byte[] dstkey, byte[]... sets);

Response<Long> zinterstore(byte[] dstkey, ZParams params, byte[]... sets);
Expand Down
Expand Up @@ -57,6 +57,8 @@ public interface MultiKeyCommandsPipeline {

Response<String> watch(String... keys);

Response<String> unwatch();

Response<Long> zinterstore(String dstkey, String... sets);

Response<Long> zinterstore(String dstkey, ZParams params, String... sets);
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/redis/clients/jedis/tests/PipeliningTest.java
Expand Up @@ -308,6 +308,24 @@ public void multiWithSync() {
assertEquals("world", r3.get());
}

@Test
public void multiWithWatch() {
String key = "foo";
String val = "bar";
List<Object> expect = new ArrayList<>();
List<Object> expMulti = new ArrayList<>();

Pipeline pipe = jedis.pipelined();
pipe.set(key, val); expect.add("OK");
pipe.watch(key); expect.add("OK");
pipe.multi(); expect.add("OK");
pipe.unwatch(); expect.add("QUEUED"); expMulti.add("OK");
pipe.get(key); expect.add("QUEUED"); expMulti.add(val);
pipe.exec(); expect.add(expMulti);

assertEquals(expect, pipe.syncAndReturnAll());
}

@Test(expected = JedisDataException.class)
public void pipelineExecShoudThrowJedisDataExceptionWhenNotInMulti() {
Pipeline pipeline = jedis.pipelined();
Expand Down

0 comments on commit fac7ddd

Please sign in to comment.