jhutchison commented on a change in pull request #5915:
URL: https://github.com/apache/geode/pull/5915#discussion_r560405644
##########
File path:
geode-redis/src/main/java/org/apache/geode/redis/internal/executor/key/RenameNxExecutor.java
##########
@@ -0,0 +1,32 @@
+package org.apache.geode.redis.internal.executor.key;
+
+import static org.apache.geode.redis.internal.RedisConstants.ERROR_NO_SUCH_KEY;
+
+import java.util.List;
+
+import org.apache.geode.redis.internal.data.ByteArrayWrapper;
+import org.apache.geode.redis.internal.executor.AbstractExecutor;
+import org.apache.geode.redis.internal.executor.RedisResponse;
+import org.apache.geode.redis.internal.netty.Command;
+import org.apache.geode.redis.internal.netty.ExecutionHandlerContext;
+
+public class RenameNxExecutor extends AbstractExecutor {
+ @Override
+ public RedisResponse executeCommand(Command command, ExecutionHandlerContext
context) {
+
+ List<ByteArrayWrapper> commandElems =
command.getProcessedCommandWrappers();
+ ByteArrayWrapper key = command.getKey();
+ ByteArrayWrapper newKey = commandElems.get(2);
+ RedisKeyCommands redisKeyCommands = getRedisKeyCommands(context);
+
+ if (redisKeyCommands.exists(newKey)) {
+ return RedisResponse.integer(0);
+ }
+
+ if (!redisKeyCommands.rename(key, newKey)) {
Review comment:
will do, thx.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]