Skip to content

Commit

Permalink
Remove WATCH from Transaction (#2033)
Browse files Browse the repository at this point in the history
* Remove WATCH from Transaction

Redis doesn't support WATCH within MULTI

* Add UNWATCH in pipeline interfaces

* Remove watch and unwatch from Transaction
  • Loading branch information
sazzad16 committed Apr 6, 2021
1 parent ec49cd7 commit b2e2cc5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 42 deletions.
12 changes: 0 additions & 12 deletions src/main/java/redis/clients/jedis/MultiKeyPipelineBase.java
Expand Up @@ -411,18 +411,6 @@ public Response<Long> sunionstore(byte[] dstkey, byte[]... keys) {
return getResponse(BuilderFactory.LONG);
}

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

@Override
public Response<String> watch(byte[]... keys) {
client.watch(keys);
return getResponse(BuilderFactory.STRING);
}

@Override
public Response<String> unwatch() {
client.unwatch();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/Pipeline.java
Expand Up @@ -156,4 +156,14 @@ public void close() {
clear();
}

public Response<String> watch(String... keys) {
client.watch(keys);
return getResponse(BuilderFactory.STRING);
}

public Response<String> watch(byte[]... keys) {
client.watch(keys);
return getResponse(BuilderFactory.STRING);
}

}
26 changes: 0 additions & 26 deletions src/main/java/redis/clients/jedis/Transaction.java
Expand Up @@ -91,30 +91,4 @@ public void setClient(Client client) {
public void close() {
clear();
}

private static final String WATCH_INSIDE_MULTI_MESSAGE = "WATCH inside MULTI is not allowed";

/**
* @param keys
* @return
* @throws UnsupportedOperationException
* @deprecated {@value #WATCH_INSIDE_MULTI_MESSAGE}
*/
@Override
@Deprecated
public Response<String> watch(String... keys) throws UnsupportedOperationException {
throw new UnsupportedOperationException(WATCH_INSIDE_MULTI_MESSAGE);
}

/**
* @param keys
* @return
* @throws UnsupportedOperationException
* @deprecated {@value #WATCH_INSIDE_MULTI_MESSAGE}
*/
@Override
@Deprecated
public Response<String> watch(byte[]... keys) throws UnsupportedOperationException {
throw new UnsupportedOperationException(WATCH_INSIDE_MULTI_MESSAGE);
}
}
Expand Up @@ -75,8 +75,6 @@ public interface MultiKeyBinaryRedisPipeline {

Response<Long> sunionstore(byte[] dstkey, byte[]... keys);

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

Response<String> unwatch();

Response<Set<byte[]>> zdiff(byte[]... keys);
Expand Down
Expand Up @@ -83,8 +83,6 @@ Response<String> blmove(String srcKey, String dstKey, ListDirection from, ListDi

Response<Long> sunionstore(String dstkey, String... keys);

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

Response<String> unwatch();

Response<Set<String>> zdiff(String... keys);
Expand Down

0 comments on commit b2e2cc5

Please sign in to comment.