diff --git a/redisson/src/main/java/org/redisson/RedissonMapCache.java b/redisson/src/main/java/org/redisson/RedissonMapCache.java index 9e460aeef..c5878a7dd 100644 --- a/redisson/src/main/java/org/redisson/RedissonMapCache.java +++ b/redisson/src/main/java/org/redisson/RedissonMapCache.java @@ -2681,7 +2681,7 @@ public class RedissonMapCache extends RedissonMap 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 " diff --git a/redisson/src/test/java/org/redisson/RedissonMapCacheTest.java b/redisson/src/test/java/org/redisson/RedissonMapCacheTest.java index ab22cca34..878a50554 100644 --- a/redisson/src/test/java/org/redisson/RedissonMapCacheTest.java +++ b/redisson/src/test/java/org/redisson/RedissonMapCacheTest.java @@ -26,6 +26,20 @@ import static org.awaitility.Awaitility.await; public class RedissonMapCacheTest extends BaseMapTest { + public static class SimpleEntryCreatedListener implements EntryCreatedListener { + + private Map map = new HashMap<>(); + + @Override + public void onCreated(EntryEvent event) { + map.put(event.getKey(), event.getValue()); + } + + public Map getCreatedEntries() { + return new HashMap<>(map); + } + } + @Test public void testExpireEntry() { RMapCache testMap = redisson.getMapCache("map"); @@ -1031,7 +1045,30 @@ public class RedissonMapCacheTest extends BaseMapTest { Assertions.assertNull(map.get(new SimpleKey("55"))); map.destroy(); } - + + @Test + public void testPutAllWithListener() throws InterruptedException { + RMapCache 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 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 map = redisson.getMapCache("simple");