K
- Key类型V
- Value类型public class CacheObj<K,V> extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected AtomicLong |
accessCount
访问次数
|
protected K |
key |
protected long |
lastAccess
上次访问时间
|
protected V |
obj |
protected long |
ttl
对象存活时长,0表示永久存活
|
Modifier | Constructor and Description |
---|---|
protected |
CacheObj(K key,
V obj,
long ttl)
构造
|
Modifier and Type | Method and Description |
---|---|
protected V |
get(boolean isUpdateLastAccess)
获取值
|
Date |
getExpiredTime()
获取过期时间,返回
null 表示永不过期 |
K |
getKey()
获取键
|
long |
getLastAccess()
获取上次访问时间
|
long |
getTtl()
获取对象存活时长,即超时总时长,0表示无限
|
V |
getValue()
获取值
|
protected boolean |
isExpired()
判断是否过期
|
String |
toString() |
protected final K key
protected final V obj
protected volatile long lastAccess
protected AtomicLong accessCount
protected final long ttl
public K getKey()
public V getValue()
public long getTtl()
public Date getExpiredTime()
null
表示永不过期null
表示永不过期public long getLastAccess()
protected boolean isExpired()
protected V get(boolean isUpdateLastAccess)
isUpdateLastAccess
- 是否更新最后访问时间Copyright © 2024. All rights reserved.