ezoerner commented on a change in pull request #6877:
URL: https://github.com/apache/geode/pull/6877#discussion_r718743630
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisKeyCommandsFunctionExecutor.java
##########
@@ -135,12 +137,22 @@ public void restore(RedisKey key, long ttl, byte[] data,
RestoreOptions options)
}
@Override
- public boolean rename(RedisKey oldKey, RedisKey newKey) {
+ public boolean rename(RedisKey oldKey, RedisKey newKey, boolean
ifTargetNotExists) {
List<RedisKey> lockOrdering = Arrays.asList(oldKey, newKey);
return stripedExecute(oldKey, lockOrdering,
- () ->
getRedisData(oldKey).rename(getRegionProvider().getLocalDataRegion(), oldKey,
- newKey));
+ () -> {
+ RedisData sourceData = getRedisData(oldKey);
+ // nonexistent source takes priority over nonexistent target
+ if (!sourceData.exists()) {
+ return false;
+ }
+ if (ifTargetNotExists && getRedisData(newKey).exists()) {
Review comment:
yes, I believe that will work
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]