From 67c1acab48405ba836639fc232da294e0dc0061d Mon Sep 17 00:00:00 2001 From: Looly Date: Mon, 17 May 2021 05:41:20 +0800 Subject: [PATCH] change to protected --- CHANGELOG.md | 3 +- .../java/cn/hutool/cache/impl/CacheObj.java | 56 +++++++++---------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 373e45c32..2bb7b6386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,13 @@ ------------------------------------------------------------------------------------------------------------- -# 5.6.6 (2021-05-14) +# 5.6.6 (2021-05-17) ### 🐣新特性 * 【cron 】 增加时间轮简单实现 * 【core 】 BeanUtil.copyToList增加重载(pr#321@Gitee) * 【core 】 SyncFinisher增加stop方法(issue#1578@Github) +* 【cache 】 CacheObj默认方法改为protected(issue#I3RIEI@Gitee) ### 🐞Bug修复 diff --git a/hutool-cache/src/main/java/cn/hutool/cache/impl/CacheObj.java b/hutool-cache/src/main/java/cn/hutool/cache/impl/CacheObj.java index 3f414add1..f9dca42a0 100644 --- a/hutool-cache/src/main/java/cn/hutool/cache/impl/CacheObj.java +++ b/hutool-cache/src/main/java/cn/hutool/cache/impl/CacheObj.java @@ -37,34 +37,6 @@ public class CacheObj implements Serializable{ this.lastAccess = System.currentTimeMillis(); } - /** - * 判断是否过期 - * - * @return 是否过期 - */ - boolean isExpired() { - if(this.ttl > 0) { - // 此处不考虑时间回拨 - return (System.currentTimeMillis() - this.lastAccess) > this.ttl; - } - return false; - } - - /** - * 获取值 - * - * @param isUpdateLastAccess 是否更新最后访问时间 - * @return 获得对象 - * @since 4.0.10 - */ - V get(boolean isUpdateLastAccess) { - if(isUpdateLastAccess) { - lastAccess = System.currentTimeMillis(); - } - accessCount.getAndIncrement(); - return this.obj; - } - /** * 获取键 * @return 键 @@ -87,4 +59,32 @@ public class CacheObj implements Serializable{ public String toString() { return "CacheObj [key=" + key + ", obj=" + obj + ", lastAccess=" + lastAccess + ", accessCount=" + accessCount + ", ttl=" + ttl + "]"; } + + /** + * 判断是否过期 + * + * @return 是否过期 + */ + protected boolean isExpired() { + if(this.ttl > 0) { + // 此处不考虑时间回拨 + return (System.currentTimeMillis() - this.lastAccess) > this.ttl; + } + return false; + } + + /** + * 获取值 + * + * @param isUpdateLastAccess 是否更新最后访问时间 + * @return 获得对象 + * @since 4.0.10 + */ + protected V get(boolean isUpdateLastAccess) { + if(isUpdateLastAccess) { + lastAccess = System.currentTimeMillis(); + } + accessCount.getAndIncrement(); + return this.obj; + } }