CacheUtil.newTimedCache增加有schedulePruneDelay参数的重载方法

This commit is contained in:
Looly 2024-04-18 16:34:39 +08:00
parent 0b9b578f61
commit cab1cade77
2 changed files with 48 additions and 30 deletions

View File

@ -2,7 +2,7 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.8.28(2024-04-16)
# 5.8.28(2024-04-18)
### 🐣新特性
* 【core 】 修正XmlUtil的omitXmlDeclaration描述注释issue#I9CPC7@Gitee
@ -10,6 +10,7 @@
* 【extra 】 设置jsch登录认证方式跳过Kerberos身份验证pr#3530@Github
* 【extra 】 增加设置验证码大小和针对alias注释pr#3533@Github
* 【json 】 JSONConfig增加setWriteLongAsString可选是否将Long写出为String类型issue#3541@Github
* 【cache 】 CacheUtil.newTimedCache增加有schedulePruneDelay参数的重载方法issue#I9HO25@Gitee
### 🐞Bug修复
* 【http 】 修复HttpUtil.urlWithFormUrlEncoded方法重复编码问题issue#3536@Github

View File

@ -9,6 +9,7 @@ import cn.hutool.cache.impl.WeakCache;
/**
* 缓存工具类
*
* @author Looly
* @since 3.0.1
*/
@ -90,6 +91,22 @@ public class CacheUtil {
return new LRUCache<>(capacity);
}
/**
* 创建定时缓存通过定时任务自动清除过期缓存对象
*
* @param <K> Key类型
* @param <V> Value类型
* @param timeout 过期时长单位毫秒
* @param schedulePruneDelay 间隔时长单位毫秒
* @return {@link TimedCache}
* @since 5.8.28
*/
public static <K, V> TimedCache<K, V> newTimedCache(long timeout, long schedulePruneDelay) {
final TimedCache<K, V> cache = newTimedCache(timeout);
cache.schedulePrune(schedulePruneDelay);
return cache;
}
/**
* 创建定时缓存.
*