mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix listener bug
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package cn.hutool.core.cache;
|
||||
|
||||
import cn.hutool.core.cache.impl.LRUCache;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
@@ -64,4 +66,16 @@ public class LRUCacheTest {
|
||||
}
|
||||
Assert.assertEquals("null123456789", sb2.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue2647Test(){
|
||||
final LRUCache<String, Integer> cache = CacheUtil.newLRUCache(3,1);
|
||||
cache.setListener((key, value) -> Console.log("Start remove k-v, key:{}, value:{}", key, value));
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
cache.put(StrUtil.format("key-{}", i), i);
|
||||
}
|
||||
|
||||
Assert.assertEquals(3, cache.size());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user