Skip to content

Commit

Permalink
More Multi and/or Pipeline check (#2031)
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 authored Oct 16, 2019
1 parent fac7ddd commit dd2ef2a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -1889,12 +1889,14 @@ public void resetState() {

@Override
public String watch(final byte[]... keys) {
checkIsInMultiOrPipeline();
client.watch(keys);
return client.getStatusCodeReply();
}

@Override
public String unwatch() {
checkIsInMultiOrPipeline();
client.unwatch();
return client.getStatusCodeReply();
}
Expand Down Expand Up @@ -3142,6 +3144,7 @@ public Long lpushx(final byte[] key, final byte[]... string) {
*/
@Override
public Long persist(final byte[] key) {
checkIsInMultiOrPipeline();
client.persist(key);
return client.getIntegerReply();
}
Expand Down Expand Up @@ -3187,6 +3190,7 @@ public Client getClient() {
*/
@Override
public byte[] brpoplpush(final byte[] source, final byte[] destination, final int timeout) {
checkIsInMultiOrPipeline();
client.brpoplpush(source, destination, timeout);
client.setTimeoutInfinite();
try {
Expand Down Expand Up @@ -3315,6 +3319,7 @@ protected static byte[][] getParamsWithBinary(List<byte[]> keys, List<byte[]> ar

@Override
public Object eval(final byte[] script, final byte[] keyCount, final byte[]... params) {
checkIsInMultiOrPipeline();
client.setTimeoutInfinite();
try {
client.eval(script, keyCount, params);
Expand Down Expand Up @@ -3346,6 +3351,7 @@ public Object evalsha(final byte[] sha1, final List<byte[]> keys, final List<byt

@Override
public Object evalsha(final byte[] sha1, final int keyCount, final byte[]... params) {
checkIsInMultiOrPipeline();
client.setTimeoutInfinite();
try {
client.evalsha(sha1, keyCount, params);
Expand Down Expand Up @@ -4047,6 +4053,7 @@ public List<byte[]> xclaim(byte[] key, byte[] groupname, byte[] consumername,
}

public Object sendCommand(ProtocolCommand cmd, byte[]... args) {
checkIsInMultiOrPipeline();
client.sendCommand(cmd, args);
return client.getOne();
}
Expand Down
35 changes: 23 additions & 12 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public Long unlink(final String... keys) {

@Override
public Long unlink(final String key) {
checkIsInMultiOrPipeline();
client.unlink(key);
return client.getIntegerReply();
}
Expand Down Expand Up @@ -1677,6 +1678,7 @@ public Double zscore(final String key, final String member) {

@Override
public String watch(final String... keys) {
checkIsInMultiOrPipeline();
client.watch(keys);
return client.getStatusCodeReply();
}
Expand Down Expand Up @@ -2592,6 +2594,7 @@ public Long lpushx(final String key, final String... string) {
*/
@Override
public Long persist(final String key) {
checkIsInMultiOrPipeline();
client.persist(key);
return client.getIntegerReply();
}
Expand Down Expand Up @@ -2627,6 +2630,7 @@ public Long linsert(final String key, final ListPosition where, final String piv
*/
@Override
public String brpoplpush(final String source, final String destination, final int timeout) {
checkIsInMultiOrPipeline();
client.brpoplpush(source, destination, timeout);
client.setTimeoutInfinite();
try {
Expand Down Expand Up @@ -2732,6 +2736,7 @@ public Long bitpos(final String key, final boolean value, final BitPosParams par
*/
@Override
public List<String> configGet(final String pattern) {
checkIsInMultiOrPipeline();
client.configGet(pattern);
return client.getMultiBulkReply();
}
Expand Down Expand Up @@ -2767,21 +2772,11 @@ public List<String> configGet(final String pattern) {
*/
@Override
public String configSet(final String parameter, final String value) {
checkIsInMultiOrPipeline();
client.configSet(parameter, value);
return client.getStatusCodeReply();
}

@Override
public Object eval(final String script, final int keyCount, final String... params) {
client.setTimeoutInfinite();
try {
client.eval(script, keyCount, params);
return getEvalResult();
} finally {
client.rollbackTimeout();
}
}

@Override
public void subscribe(final JedisPubSub jedisPubSub, final String... channels) {
client.setTimeoutInfinite();
Expand Down Expand Up @@ -2826,6 +2821,18 @@ protected static String[] getParams(List<String> keys, List<String> args) {
return params;
}

@Override
public Object eval(final String script, final int keyCount, final String... params) {
checkIsInMultiOrPipeline();
client.eval(script, keyCount, params);
client.setTimeoutInfinite();
try {
return getEvalResult();
} finally {
client.rollbackTimeout();
}
}

@Override
public Object eval(final String script, final List<String> keys, final List<String> args) {
return eval(script, keys.size(), getParams(keys, args));
Expand Down Expand Up @@ -3298,6 +3305,7 @@ public String clusterNodes() {

@Override
public String readonly() {
checkIsInMultiOrPipeline();
client.readonly();
return client.getStatusCodeReply();
}
Expand Down Expand Up @@ -3626,18 +3634,21 @@ public List<GeoRadiusResponse> georadiusByMemberReadonly(final String key, final

@Override
public String moduleLoad(final String path) {
checkIsInMultiOrPipeline();
client.moduleLoad(path);
return client.getStatusCodeReply();
}

@Override
public String moduleUnload(final String name) {
checkIsInMultiOrPipeline();
client.moduleUnload(name);
return client.getStatusCodeReply();
}

@Override
public List<Module> moduleList() {
checkIsInMultiOrPipeline();
client.moduleList();
return BuilderFactory.MODULE_LIST.build(client.getObjectMultiBulkReply());
}
Expand Down Expand Up @@ -3823,14 +3834,14 @@ public List<StreamPendingEntry> xpending(final String key, final String groupnam
@Override
public List<StreamEntry> xclaim(String key, String group, String consumername, long minIdleTime, long newIdleTime,
int retries, boolean force, StreamEntryID... ids) {

checkIsInMultiOrPipeline();
client.xclaim( key, group, consumername, minIdleTime, newIdleTime, retries, force, ids);

return BuilderFactory.STREAM_ENTRY_LIST.build(client.getObjectMultiBulkReply());
}

public Object sendCommand(ProtocolCommand cmd, String... args) {
checkIsInMultiOrPipeline();
client.sendCommand(cmd, args);
return client.getOne();
}
Expand Down

0 comments on commit dd2ef2a

Please sign in to comment.