[cleanup] erefactor/EclipseJdt - Remove trailing whitespace - All lines

EclipseJdt cleanup 'RemoveAllTrailingWhitespace' applied by erefactor.

For EclipseJdt see https://www.eclipse.org/eclipse/news/4.18/jdt.php
For erefactor see https://github.com/cal101/erefactor
This commit is contained in:
cal101
2021-02-27 09:54:17 +00:00
parent b285db71cd
commit 83c30bcfb7
20 changed files with 94 additions and 94 deletions

View File

@@ -14,7 +14,7 @@ import org.junit.Test;
*
*/
public class CacheTest {
@Test
public void fifoCacheTest(){
Cache<String,String> fifoCache = CacheUtil.newFIFOCache(3);
@@ -28,22 +28,22 @@ public class CacheTest {
fifoCache.put("key2", "value2", DateUnit.SECOND.getMillis() * 3);
fifoCache.put("key3", "value3", DateUnit.SECOND.getMillis() * 3);
fifoCache.put("key4", "value4", DateUnit.SECOND.getMillis() * 3);
//由于缓存容量只有3当加入第四个元素的时候根据FIFO规则最先放入的对象将被移除
String value1 = fifoCache.get("key1");
Assert.assertNull(value1);
}
@Test
public void lfuCacheTest(){
Cache<String, String> lfuCache = CacheUtil.newLFUCache(3);
lfuCache.put("key1", "value1", DateUnit.SECOND.getMillis() * 3);
//使用次数+1
lfuCache.get("key1");
lfuCache.get("key1");
lfuCache.put("key2", "value2", DateUnit.SECOND.getMillis() * 3);
lfuCache.put("key3", "value3", DateUnit.SECOND.getMillis() * 3);
lfuCache.put("key4", "value4", DateUnit.SECOND.getMillis() * 3);
//由于缓存容量只有3当加入第四个元素的时候根据LFU规则最少使用的将被移除2,3被移除
String value1 = lfuCache.get("key1");
String value2 = lfuCache.get("key2");
@@ -52,7 +52,7 @@ public class CacheTest {
Assert.assertNull(value2);
Assert.assertNull(value3);
}
@Test
public void lruCacheTest(){
Cache<String, String> lruCache = CacheUtil.newLRUCache(3);
@@ -71,7 +71,7 @@ public class CacheTest {
String value2 = lruCache.get("key2");
Assert.assertNull(value2);
}
@Test
public void timedCacheTest(){
TimedCache<String, String> timedCache = CacheUtil.newTimedCache(4);
@@ -80,29 +80,29 @@ public class CacheTest {
timedCache.put("key2", "value2", DateUnit.SECOND.getMillis() * 5);//5秒过期
timedCache.put("key3", "value3");//默认过期(4毫秒)
timedCache.put("key4", "value4", Long.MAX_VALUE);//永不过期
//启动定时任务每5毫秒秒检查一次过期
timedCache.schedulePrune(5);
//等待5毫秒
ThreadUtil.sleep(5);
//5毫秒后由于value2设置了5毫秒过期因此只有value2被保留下来
String value1 = timedCache.get("key1");
Assert.assertNull(value1);
String value2 = timedCache.get("key2");
Assert.assertEquals("value2", value2);
//5毫秒后由于设置了默认过期key3只被保留4毫秒因此为null
String value3 = timedCache.get("key3");
Assert.assertNull(value3);
String value3Supplier = timedCache.get("key3", () -> "Default supplier");
Assert.assertEquals("Default supplier", value3Supplier);
// 永不过期
String value4 = timedCache.get("key4");
Assert.assertEquals("value4", value4);
//取消定时清理
timedCache.cancelPruneSchedule();
}