Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pom.xml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should revert

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<junit.version>5.13.4</junit.version>
<!-- Default JVM options for tests -->
<JVM_OPTS></JVM_OPTS>
<argLine></argLine>
<failsafeSuffixArgLine></failsafeSuffixArgLine>
<failsafeTaggedArgLine></failsafeTaggedArgLine>
<failsafeScenarioArgLine></failsafeScenarioArgLine>
<!-- Default excluded groups for tests - can be overridden from command line -->
<excludedGroupsForUnitTests>integration,scenario</excludedGroupsForUnitTests>
<skipUnitTests>false</skipUnitTests>
Expand Down Expand Up @@ -349,7 +353,7 @@
<version>${maven.surefire.version}</version>
<configuration>
<skipTests>${skipUnitTests}</skipTests>
<argLine>@{argLine} ${JVM_OPTS}</argLine>
<argLine>${argLine} ${JVM_OPTS}</argLine>
<systemPropertyVariables>
<redis-hosts>${redis-hosts}</redis-hosts>
</systemPropertyVariables>
Expand All @@ -368,7 +372,7 @@
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<argLine>@{failsafeSuffixArgLine} ${JVM_OPTS}</argLine>
<argLine>${failsafeSuffixArgLine} ${JVM_OPTS}</argLine>
<systemPropertyVariables>
<redis-hosts>${redis-hosts}</redis-hosts>
</systemPropertyVariables>
Expand All @@ -394,7 +398,7 @@
</goals>
<configuration>
<skip>${skipIntegrationTests}</skip>
<argLine>@{failsafeTaggedArgLine} ${JVM_OPTS}</argLine>
<argLine>${failsafeTaggedArgLine} ${JVM_OPTS}</argLine>
<groups>integration</groups>
<excludedGroups>scenario,unit</excludedGroups>
<includes>
Expand All @@ -411,7 +415,7 @@
</goals>
<configuration>
<skip>${skipIntegrationTests}</skip>
<argLine>@{failsafeSuffixArgLine} ${JVM_OPTS}</argLine>
<argLine>${failsafeSuffixArgLine} ${JVM_OPTS}</argLine>
<excludedGroups>scenario,unit</excludedGroups>
<includes>
<include>**/*IT.java</include>
Expand All @@ -429,7 +433,7 @@
</goals>
<configuration>
<skip>${skipScenarioTests}</skip>
<argLine>@{failsafeScenarioArgLine} ${JVM_OPTS}</argLine>
<argLine>${failsafeScenarioArgLine} ${JVM_OPTS}</argLine>
<groups>scenario</groups>
<excludedGroups>integration,unit</excludedGroups>
<includes>
Expand Down Expand Up @@ -638,7 +642,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<argLine>@{argLine} ${JVM_OPTS}</argLine>
<argLine>${argLine} ${JVM_OPTS}</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
83 changes: 80 additions & 3 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import redis.clients.jedis.timeseries.*;
import redis.clients.jedis.timeseries.TimeSeriesProtocol.*;
import redis.clients.jedis.util.KeyValue;
import redis.clients.jedis.conditions.ValueCondition;

public class CommandObjects {

Expand All @@ -49,7 +50,7 @@ protected RedisProtocol getProtocol() {

protected volatile CommandKeyArgumentPreProcessor keyPreProcessor = null;
private JedisBroadcastAndRoundRobinConfig broadcastAndRoundRobinConfig = null;
private Lock mapperLock = new ReentrantLock(true);
private Lock mapperLock = new ReentrantLock(true);
private volatile JsonObjectMapper jsonObjectMapper;
private final AtomicInteger searchDialect = new AtomicInteger(SearchProtocol.DEFAULT_DIALECT);

Expand Down Expand Up @@ -346,6 +347,18 @@ public final CommandObject<Long> del(byte[]... keys) {
return new CommandObject<>(commandArguments(DEL).keys((Object[]) keys), BuilderFactory.LONG);
}

public final CommandObject<Long> delex(String key, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.DELEX).key(key);
cond.addTo(ca);
return new CommandObject<>(ca, BuilderFactory.LONG);
}

public final CommandObject<Long> delex(byte[] key, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.DELEX).key(key);
cond.addTo(ca);
return new CommandObject<>(ca, BuilderFactory.LONG);
}

public final CommandObject<Long> unlink(String key) {
return new CommandObject<>(commandArguments(UNLINK).key(key), BuilderFactory.LONG);
}
Expand Down Expand Up @@ -454,14 +467,74 @@ public final CommandObject<String> set(byte[] key, byte[] value) {
return new CommandObject<>(commandArguments(Command.SET).key(key).add(value), BuilderFactory.STRING);
}

public final CommandObject<String> set(String key, String value, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.SET).key(key).add(value);
cond.addTo(ca);
return new CommandObject<>(ca, BuilderFactory.STRING);
}

public final CommandObject<String> setGet(String key, String value, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.SET).key(key).add(value);
cond.addTo(ca);
ca.add(Keyword.GET);
return new CommandObject<>(ca, BuilderFactory.STRING);
}

public final CommandObject<String> set(byte[] key, byte[] value, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.SET).key(key).add(value);
cond.addTo(ca);
return new CommandObject<>(ca, BuilderFactory.STRING);
}

public final CommandObject<byte[]> setGet(byte[] key, byte[] value, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.SET).key(key).add(value);
cond.addTo(ca);
ca.add(Keyword.GET);
return new CommandObject<>(ca, BuilderFactory.BINARY);
}

public final CommandObject<String> set(byte[] key, byte[] value, SetParams params) {
return new CommandObject<>(commandArguments(Command.SET).key(key).add(value).addParams(params), BuilderFactory.STRING);
}

public final CommandObject<String> set(String key, String value, SetParams params, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.SET).key(key).add(value);
cond.addTo(ca);
ca.addParams(params);
return new CommandObject<>(ca, BuilderFactory.STRING);
}

public final CommandObject<String> setGet(String key, String value, SetParams params, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.SET).key(key).add(value);
cond.addTo(ca);
ca.addParams(params);
ca.add(Keyword.GET);
return new CommandObject<>(ca, BuilderFactory.STRING);
}

public final CommandObject<String> set(byte[] key, byte[] value, SetParams params, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.SET).key(key).add(value);
cond.addTo(ca);
ca.addParams(params);
return new CommandObject<>(ca, BuilderFactory.STRING);
}

public final CommandObject<byte[]> setGet(byte[] key, byte[] value, SetParams params, ValueCondition cond) {
CommandArguments ca = commandArguments(Command.SET).key(key).add(value);
cond.addTo(ca);
ca.addParams(params);
ca.add(Keyword.GET);
return new CommandObject<>(ca, BuilderFactory.BINARY);
}

public final CommandObject<String> get(String key) {
return new CommandObject<>(commandArguments(Command.GET).key(key), BuilderFactory.STRING);
}

public final CommandObject<String> digestKey(String key) {
return new CommandObject<>(commandArguments(Command.DIGEST).key(key), BuilderFactory.STRING);
}

public final CommandObject<String> setGet(String key, String value) {
return new CommandObject<>(commandArguments(Command.SET).key(key).add(value).add(Keyword.GET), BuilderFactory.STRING);
}
Expand All @@ -479,6 +552,10 @@ public final CommandObject<String> getEx(String key, GetExParams params) {
return new CommandObject<>(commandArguments(Command.GETEX).key(key).addParams(params), BuilderFactory.STRING);
}

public final CommandObject<byte[]> digestKey(byte[] key) {
return new CommandObject<>(commandArguments(Command.DIGEST).key(key), BuilderFactory.BINARY);
}

public final CommandObject<byte[]> get(byte[] key) {
return new CommandObject<>(commandArguments(Command.GET).key(key), BuilderFactory.BINARY);
}
Expand Down Expand Up @@ -2977,7 +3054,7 @@ public final CommandObject<List<Object>> xreadGroup(byte[] groupName, byte[] con
}

public final CommandObject<List<Map.Entry<byte[], List<StreamEntryBinary>>>> xreadGroupBinary(
byte[] groupName, byte[] consumer, XReadGroupParams xReadGroupParams,
byte[] groupName, byte[] consumer, XReadGroupParams xReadGroupParams,
Map.Entry<byte[], StreamEntryID>... streams) {
CommandArguments args = commandArguments(XREADGROUP)
.add(GROUP).add(groupName).add(consumer)
Expand All @@ -2992,7 +3069,7 @@ public final CommandObject<List<Map.Entry<byte[], List<StreamEntryBinary>>>> xre
}

public final CommandObject<Map<byte[], List<StreamEntryBinary>>> xreadGroupBinaryAsMap(
byte[] groupName, byte[] consumer, XReadGroupParams xReadGroupParams,
byte[] groupName, byte[] consumer, XReadGroupParams xReadGroupParams,
Map.Entry<byte[], StreamEntryID>... streams) {
CommandArguments args = commandArguments(XREADGROUP)
.add(GROUP).add(groupName).add(consumer)
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import javax.net.ssl.SSLSocketFactory;

import redis.clients.jedis.Protocol.*;
import redis.clients.jedis.annots.Experimental;
import redis.clients.jedis.args.*;
import redis.clients.jedis.commands.*;
import redis.clients.jedis.conditions.ValueCondition;
import redis.clients.jedis.exceptions.InvalidURIException;
import redis.clients.jedis.exceptions.JedisConnectionException;
import redis.clients.jedis.exceptions.JedisException;
Expand Down Expand Up @@ -490,6 +492,24 @@ public String set(final byte[] key, final byte[] value, final SetParams params)
return connection.executeCommand(commandObjects.set(key, value, params));
}

@Override
public String set(final byte[] key, final byte[] value, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.set(key, value, condition));
}

@Override
public String set(final byte[] key, final byte[] value, final SetParams params, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.set(key, value, params, condition));
}

@Override
public byte[] setGet(final byte[] key, final byte[] value, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.setGet(key, value, condition));
}

/**
* Get the value of the specified key. If the key does not exist the special value 'nil' is
* returned. If the value stored at key is not a string an error is returned because GET can only
Expand All @@ -505,6 +525,12 @@ public byte[] get(final byte[] key) {
return connection.executeCommand(commandObjects.get(key));
}

@Override
public byte[] digestKey(final byte[] key) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.digestKey(key));
}

@Override
public byte[] setGet(final byte[] key, final byte[] value) {
checkIsInMultiOrPipeline();
Expand All @@ -517,6 +543,12 @@ public byte[] setGet(final byte[] key, final byte[] value, final SetParams param
return connection.executeCommand(commandObjects.setGet(key, value, params));
}

@Override
public byte[] setGet(final byte[] key, final byte[] value, final SetParams params, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.setGet(key, value, params, condition));
}

/**
* Get the value of key and delete the key. This command is similar to GET, except for the fact
* that it also deletes the key on success (if and only if the key's value type is a string).
Expand Down Expand Up @@ -573,6 +605,12 @@ public long del(final byte[]... keys) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.del(keys));
}
@Override
public long delex(final byte[] key, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.delex(key, condition));
}


@Override
public long del(final byte[] key) {
Expand Down Expand Up @@ -5100,6 +5138,24 @@ public String set(final String key, final String value, final SetParams params)
return connection.executeCommand(commandObjects.set(key, value, params));
}

@Override
public String set(final String key, final String value, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.set(key, value, condition));
}

@Override
public String set(final String key, final String value, final SetParams params, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.set(key, value, params, condition));
}

@Override
public String setGet(final String key, final String value, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.setGet(key, value, condition));
}

/**
* Get the value of the specified key. If the key does not exist the special value 'nil' is
* returned. If the value stored at key is not a string an error is returned because GET can only
Expand All @@ -5121,6 +5177,12 @@ public String setGet(final String key, final String value) {
return connection.executeCommand(commandObjects.setGet(key, value));
}

@Override
public String setGet(final String key, final String value, final SetParams params, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.setGet(key, value, params, condition));
}

@Override
public String setGet(final String key, final String value, final SetParams params) {
checkIsInMultiOrPipeline();
Expand All @@ -5147,6 +5209,18 @@ public String getEx(String key, GetExParams params) {
return connection.executeCommand(commandObjects.getEx(key, params));
}

@Override
public String digestKey(final String key) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.digestKey(key));
}

@Override
public long delex(final String key, final ValueCondition condition) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.delex(key, condition));
}

/**
* Test if the specified keys exist. The command returns the number of keys exist.
* Time complexity: O(N)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/redis/clients/jedis/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static final byte[] toByteArray(final double value) {

public static enum Command implements ProtocolCommand {

PING, AUTH, HELLO, SET, GET, GETDEL, GETEX, EXISTS, DEL, UNLINK, TYPE, FLUSHDB, FLUSHALL, MOVE,
PING, AUTH, HELLO, SET, GET, GETDEL, GETEX, DIGEST, EXISTS, DEL, DELEX, UNLINK, TYPE, FLUSHDB, FLUSHALL, MOVE,
KEYS, RANDOMKEY, RENAME, RENAMENX, DUMP, RESTORE, DBSIZE, SELECT, SWAPDB, MIGRATE, ECHO, //
EXPIRE, EXPIREAT, EXPIRETIME, PEXPIRE, PEXPIREAT, PEXPIRETIME, TTL, PTTL, // <-- key expiration
MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, SORT_RO, INFO, SHUTDOWN, MONITOR, CONFIG, LCS, //
Expand Down Expand Up @@ -334,7 +334,7 @@ public static enum Keyword implements Rawable {
STREAMS, CREATE, MKSTREAM, SETID, DESTROY, DELCONSUMER, MAXLEN, GROUP, IDLE, TIME, BLOCK, NOACK,
RETRYCOUNT, STREAM, GROUPS, CONSUMERS, JUSTID, WITHVALUES, NOMKSTREAM, MINID, CREATECONSUMER,
SETUSER, GETUSER, DELUSER, WHOAMI, USERS, CAT, GENPASS, LOG, SAVE, DRYRUN, COPY, AUTH, AUTH2,
NX, XX, EX, PX, EXAT, PXAT, ABSTTL, KEEPTTL, INCR, LT, GT, CH, INFO, PAUSE, UNPAUSE, UNBLOCK,
NX, XX, IFEQ, IFNE, IFDEQ, IFDNE, EX, PX, EXAT, PXAT, ABSTTL, KEEPTTL, INCR, LT, GT, CH, INFO, PAUSE, UNPAUSE, UNBLOCK,
REV, WITHCOORD, WITHDIST, WITHHASH, ANY, FROMMEMBER, FROMLONLAT, BYRADIUS, BYBOX, BYLEX, BYSCORE,
STOREDIST, TO, FORCE, TIMEOUT, DB, UNLOAD, ABORT, IDX, MINMATCHLEN, WITHMATCHLEN, FULL,
DELETE, LIBRARYNAME, WITHCODE, DESCRIPTION, GETKEYS, GETKEYSANDFLAGS, DOCS, FILTERBY, DUMP,
Expand Down
Loading
Loading