Skip to content

Commit

Permalink
Fixed - RListMultimap and RSetMultimap unable to replaceValues with e…
Browse files Browse the repository at this point in the history
…mpty collection #4571
  • Loading branch information
Nikita Koksharov committed Sep 30, 2022
1 parent aadb6cf commit 35c371c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Expand Up @@ -310,7 +310,9 @@ public RFuture<Collection<V>> replaceValuesAsync(K key, Iterable<? extends V> va
"redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " +
"local members = redis.call('lrange', KEYS[2], 0, -1); " +
"redis.call('del', KEYS[2]); " +
"redis.call('rpush', KEYS[2], unpack(ARGV, 3, #ARGV)); " +
"if #ARGV > 2 then " +
"redis.call('rpush', KEYS[2], unpack(ARGV, 3, #ARGV)); " +
"end; " +
"return members; ",
Arrays.<Object>asList(getRawName(), setName), params.toArray());
}
Expand Down
4 changes: 3 additions & 1 deletion redisson/src/main/java/org/redisson/RedissonSetMultimap.java
Expand Up @@ -309,7 +309,9 @@ public RFuture<Collection<V>> replaceValuesAsync(K key, Iterable<? extends V> va
"redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " +
"local members = redis.call('smembers', KEYS[2]); " +
"redis.call('del', KEYS[2]); " +
"redis.call('sadd', KEYS[2], unpack(ARGV, 3, #ARGV)); " +
"if #ARGV > 2 then " +
"redis.call('sadd', KEYS[2], unpack(ARGV, 3, #ARGV)); " +
"end; " +
"return members; ",
Arrays.<Object>asList(getRawName(), setName), params.toArray());
}
Expand Down
Expand Up @@ -362,6 +362,12 @@ public void testReplaceValues() {

List<SimpleValue> allValues = map.getAll(new SimpleKey("0"));
assertThat(allValues).containsExactlyElementsOf(values);

List<SimpleValue> oldValues2 = map.replaceValues(new SimpleKey("0"), Collections.emptyList());
assertThat(oldValues2).containsExactlyElementsOf(values);

List<SimpleValue> vals = map.getAll(new SimpleKey("0"));
assertThat(vals).isEmpty();
}

@Test
Expand Down
Expand Up @@ -429,7 +429,14 @@ public void testReplaceValues() {
assertThat(oldValues).containsOnly(new SimpleValue("1"));

Set<SimpleValue> allValues = map.getAll(new SimpleKey("0"));
assertThat(allValues).containsOnlyElementsOf(values);
assertThat(allValues).containsExactlyElementsOf(values);

Set<SimpleValue> oldValues2 = map.replaceValues(new SimpleKey("0"), Collections.emptyList());
assertThat(oldValues2).containsExactlyElementsOf(values);

Set<SimpleValue> vals = map.getAll(new SimpleKey("0"));
assertThat(vals).isEmpty();

}

@Test
Expand Down

0 comments on commit 35c371c

Please sign in to comment.