mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
change to protected
This commit is contained in:
parent
2c1d10d952
commit
67c1acab48
@ -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修复
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user