This commit is contained in:
Looly 2022-03-30 11:48:20 +08:00
parent d981be8cd1
commit 11bf2c3743

View File

@ -1,7 +1,10 @@
package cn.hutool.cache;
import cn.hutool.cache.impl.LRUCache;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.RandomUtil;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
@ -13,6 +16,18 @@ import java.util.concurrent.CountDownLatch;
*/
public class LRUCacheTest {
@Test
@Ignore
public void putTest(){
//https://github.com/dromara/hutool/issues/2227
LRUCache<String, String> cache = CacheUtil.newLRUCache(100, 10);
for (int i = 0; i < 10000; i++) {
//ThreadUtil.execute(()-> cache.put(RandomUtil.randomString(5), "1243", 10));
ThreadUtil.execute(()-> cache.get(RandomUtil.randomString(5), ()->RandomUtil.randomString(10)));
}
ThreadUtil.sleep(3000);
}
@Test
public void readWriteTest() throws InterruptedException {
LRUCache<Integer, Integer> cache = CacheUtil.newLRUCache(10);