mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
CacheUtil.newTimedCache增加有schedulePruneDelay参数的重载方法
This commit is contained in:
parent
0b9b578f61
commit
cab1cade77
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建定时缓存.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user