Merge branch 'master' of github.com:redisson/redisson

pull/4237/merge
mrniko 3 weeks ago
commit f046cd0b05

@ -2681,7 +2681,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_VOID,
"local currentTime = tonumber(table.remove(ARGV, 1)); " + // index is the first parameter
"local publishCommand = tonumber(table.remove(ARGV, 1)); " + // index is the first parameter
"local publishCommand = table.remove(ARGV, 1); " + // index is the first parameter
"local maxSize = tonumber(redis.call('hget', KEYS[8], 'max-size'));" +
"local mode = redis.call('hget', KEYS[8], 'mode'); " +
"for i, value in ipairs(ARGV) do "

@ -26,6 +26,20 @@ import static org.awaitility.Awaitility.await;
public class RedissonMapCacheTest extends BaseMapTest {
public static class SimpleEntryCreatedListener implements EntryCreatedListener {
private Map<Object, Object> map = new HashMap<>();
@Override
public void onCreated(EntryEvent event) {
map.put(event.getKey(), event.getValue());
}
public Map<Object, Object> getCreatedEntries() {
return new HashMap<>(map);
}
}
@Test
public void testExpireEntry() {
RMapCache<String, String> testMap = redisson.getMapCache("map");
@ -1032,6 +1046,29 @@ public class RedissonMapCacheTest extends BaseMapTest {
map.destroy();
}
@Test
public void testPutAllWithListener() throws InterruptedException {
RMapCache<SimpleKey, SimpleValue> map = redisson.getMapCache("simple");
SimpleEntryCreatedListener listener = new SimpleEntryCreatedListener();
map.addListener(listener);
Assertions.assertNull(map.get(new SimpleKey("33")));
Assertions.assertNull(map.get(new SimpleKey("55")));
Map<SimpleKey, SimpleValue> entries = new HashMap<>();
entries.put(new SimpleKey("33"), new SimpleValue("44"));
entries.put(new SimpleKey("55"), new SimpleValue("66"));
map.putAll(entries);
SimpleValue val1 = map.get(new SimpleKey("33"));
Assertions.assertEquals("44", val1.getValue());
SimpleValue val2 = map.get(new SimpleKey("55"));
Assertions.assertEquals("66", val2.getValue());
Assertions.assertEquals(entries, listener.getCreatedEntries());
map.destroy();
}
@Test
public void testPutIfAbsentTTL() throws Exception {
RMapCache<SimpleKey, SimpleValue> map = redisson.getMapCache("simple");

Loading…
Cancel
Save