Skip to content

Commit

Permalink
GETSET command is deprecated since Redis 6.2.0 (#3768)
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 authored Mar 12, 2024
1 parent 7515d5a commit 5733cd6
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ public final CommandObject<String> setGet(String key, String value) {
}

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

public final CommandObject<String> getDel(String key) {
Expand All @@ -468,8 +468,8 @@ public final CommandObject<byte[]> setGet(byte[] key, byte[] value) {
}

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

public final CommandObject<byte[]> getDel(byte[] key) {
Expand All @@ -480,10 +480,18 @@ public final CommandObject<byte[]> getEx(byte[] key, GetExParams params) {
return new CommandObject<>(commandArguments(Command.GETEX).key(key).addParams(params), BuilderFactory.BINARY);
}

/**
* @deprecated Use {@link CommandObjects#setGet(java.lang.String, java.lang.String)}.
*/
@Deprecated
public final CommandObject<String> getSet(String key, String value) {
return new CommandObject<>(commandArguments(Command.GETSET).key(key).add(value), BuilderFactory.STRING);
}

/**
* @deprecated Use {@link CommandObjects#setGet(byte[], byte[])}.
*/
@Deprecated
public final CommandObject<byte[]> getSet(byte[] key, byte[] value) {
return new CommandObject<>(commandArguments(Command.GETSET).key(key).add(value), BuilderFactory.BINARY);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,9 @@ public long move(final byte[] key, final int dbIndex) {
* @param key
* @param value
* @return Bulk reply
* @deprecated Use {@link Jedis#setGet(byte[], byte[])}.
*/
@Deprecated
@Override
public byte[] getSet(final byte[] key, final byte[] value) {
checkIsInMultiOrPipeline();
Expand Down Expand Up @@ -5316,7 +5318,9 @@ public long move(final String key, final int dbIndex) {
* @param key
* @param value
* @return Bulk reply
* @deprecated Use {@link Jedis#setGet(java.lang.String, java.lang.String)}.
*/
@Deprecated
@Override
public String getSet(final String key, final String value) {
checkIsInMultiOrPipeline();
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/redis/clients/jedis/PipeliningBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ public Response<String> get(String key) {
return appendCommand(commandObjects.get(key));
}

@Override
public Response<String> setGet(String key, String value) {
return appendCommand(commandObjects.setGet(key, value));
}

@Override
public Response<String> setGet(String key, String value, SetParams params) {
return appendCommand(commandObjects.setGet(key, value, params));
Expand Down Expand Up @@ -315,6 +320,10 @@ public Response<String> getrange(String key, long startOffset, long endOffset) {
return appendCommand(commandObjects.getrange(key, startOffset, endOffset));
}

/**
* @deprecated Use {@link PipeliningBase#setGet(java.lang.String, java.lang.String)}.
*/
@Deprecated
@Override
public Response<String> getSet(String key, String value) {
return appendCommand(commandObjects.getSet(key, value));
Expand Down Expand Up @@ -3114,6 +3123,11 @@ public Response<byte[]> get(byte[] key) {
return appendCommand(commandObjects.get(key));
}

@Override
public Response<byte[]> setGet(byte[] key, byte[] value) {
return appendCommand(commandObjects.setGet(key, value));
}

@Override
public Response<byte[]> setGet(byte[] key, byte[] value, SetParams params) {
return appendCommand(commandObjects.setGet(key, value, params));
Expand Down Expand Up @@ -3149,6 +3163,10 @@ public Response<byte[]> getrange(byte[] key, long startOffset, long endOffset) {
return appendCommand(commandObjects.getrange(key, startOffset, endOffset));
}

/**
* @deprecated Use {@link PipeliningBase#setGet(byte[], byte[])}.
*/
@Deprecated
@Override
public Response<byte[]> getSet(byte[] key, byte[] value) {
return appendCommand(commandObjects.getSet(key, value));
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,10 @@ public byte[] getrange(byte[] key, long startOffset, long endOffset) {
return executeCommand(commandObjects.getrange(key, startOffset, endOffset));
}

/**
* @deprecated Use {@link UnifiedJedis#setGet(java.lang.String, java.lang.String)}.
*/
@Deprecated
@Override
public String getSet(String key, String value) {
return executeCommand(commandObjects.getSet(key, value));
Expand All @@ -845,6 +849,10 @@ public String psetex(String key, long milliseconds, String value) {
return executeCommand(commandObjects.psetex(key, milliseconds, value));
}

/**
* @deprecated Use {@link UnifiedJedis#setGet(byte[], byte[])}.
*/
@Deprecated
@Override
public byte[] getSet(byte[] key, byte[] value) {
return executeCommand(commandObjects.getSet(key, value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public interface StringBinaryCommands extends BitBinaryCommands {

byte[] getrange(byte[] key, long startOffset, long endOffset);

/**
* @deprecated Use {@link StringBinaryCommands#setGet(byte[], byte[])}.
*/
@Deprecated
byte[] getSet(byte[] key, byte[] value);

long setnx(byte[] key, byte[] value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public interface StringCommands extends BitCommands {
* @param key
* @param value
* @return The old value that was stored in key
* @deprecated Use {@link StringCommands#setGet(java.lang.String, java.lang.String)}.
*/
@Deprecated
String getSet(String key, String value);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface StringPipelineBinaryCommands extends BitPipelineBinaryCommands

Response<byte[]> get(byte[] key);

Response<byte[]> setGet(byte[] key, byte[] value);

Response<byte[]> setGet(byte[] key, byte[] value, SetParams params);

Response<byte[]> getDel(byte[] key);
Expand All @@ -26,6 +28,10 @@ public interface StringPipelineBinaryCommands extends BitPipelineBinaryCommands

Response<byte[]> getrange(byte[] key, long startOffset, long endOffset);

/**
* @deprecated {@link StringPipelineBinaryCommands#setGet(byte[], byte[], redis.clients.jedis.params.SetParams)}.
*/
@Deprecated
Response<byte[]> getSet(byte[] key, byte[] value);

Response<Long> setnx(byte[] key, byte[] value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface StringPipelineCommands extends BitPipelineCommands {

Response<String> get(String key);

Response<String> setGet(String key, String value);

Response<String> setGet(String key, String value, SetParams params);

Response<String> getDel(String key);
Expand All @@ -26,6 +28,10 @@ public interface StringPipelineCommands extends BitPipelineCommands {

Response<String> getrange(String key, long startOffset, long endOffset);

/**
* @deprecated Use {@link StringPipelineCommands#setGet(java.lang.String, java.lang.String)}.
*/
@Deprecated
Response<String> getSet(String key, String value);

Response<Long> setnx(String key, String value);
Expand Down

0 comments on commit 5733cd6

Please sign in to comment.