change to protected

This commit is contained in:
Looly 2021-05-17 05:41:20 +08:00
parent 2c1d10d952
commit 67c1acab48
2 changed files with 30 additions and 29 deletions

View File

@ -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默认方法改为protectedissue#I3RIEI@Gitee
### 🐞Bug修复

View File

@ -37,34 +37,6 @@ public class CacheObj<K, V> 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<K, V> 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;
}
}