Fixed - JCache.removeAll doesn't work. #1574

pull/1547/head
Nikita 7 years ago
parent e37c9d3741
commit 24146f776b

@ -58,7 +58,6 @@ import org.redisson.api.RLock;
import org.redisson.api.RSemaphore;
import org.redisson.api.RTopic;
import org.redisson.api.listener.MessageListener;
import org.redisson.client.ChannelName;
import org.redisson.client.RedisClient;
import org.redisson.client.codec.Codec;
import org.redisson.client.protocol.RedisCommand;
@ -826,7 +825,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
return evalWrite(getName(), codec, RedisCommands.EVAL_LONG,
"redis.call('zrem', KEYS[2], unpack(ARGV)); "
+ "return redis.call('hdel', KEYS[1], unpack(ARGV)); ",
Arrays.<Object>asList(getName(), getTimeoutSetName()), params);
Arrays.<Object>asList(getName(), getTimeoutSetName()), params.toArray());
}
private List<Object> getAndPutValueLocked(K key, V value) {

@ -12,6 +12,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -42,6 +43,37 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
public class JCacheTest extends BaseTest {
@Test
public void testRemoveAll() throws Exception {
RedisProcess runner = new RedisRunner()
.nosave()
.randomDir()
.port(6311)
.run();
URL configUrl = getClass().getResource("redisson-jcache.json");
Config cfg = Config.fromJSON(configUrl);
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg);
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager()
.createCache("test", config);
cache.put("1", "2");
cache.put("3", "4");
cache.put("4", "4");
cache.put("5", "5");
Set<? extends String> keys = new HashSet<String>(Arrays.asList("1", "3", "4", "5"));
cache.removeAll(keys);
assertThat(cache.containsKey("1")).isFalse();
assertThat(cache.containsKey("3")).isFalse();
assertThat(cache.containsKey("4")).isFalse();
assertThat(cache.containsKey("5")).isFalse();
cache.close();
runner.stop();
}
@Test
public void testGetAll() throws Exception {
RedisProcess runner = new RedisRunner()
@ -52,7 +84,6 @@ public class JCacheTest extends BaseTest {
URL configUrl = getClass().getResource("redisson-jcache.json");
Config cfg = Config.fromJSON(configUrl);
cfg.useSingleServer().setTimeout(300000);
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg);
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager()

Loading…
Cancel
Save