Class CacheObject<K,V>

java.lang.Object
org.miaixz.bus.core.cache.provider.CacheObject<K,V>
Type Parameters:
K - Key类型
V - Value类型
All Implemented Interfaces:
Serializable

public class CacheObject<K,V> extends Object implements Serializable
缓存对象
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Field Details

    • key

      protected final K key
    • obj

      protected final V obj
    • ttl

      protected final long ttl
      对象存活时长,0表示永久存活
    • lastAccess

      protected volatile long lastAccess
      上次访问时间
    • accessCount

      protected AtomicLong accessCount
      访问次数
  • Constructor Details

    • CacheObject

      protected CacheObject(K key, V obj, long ttl)
      构造
      Parameters:
      key - 键
      obj - 值
      ttl - 超时时长
  • Method Details

    • getKey

      public K getKey()
      获取键
      Returns:
    • getValue

      public V getValue()
      获取值
      Returns:
    • getTtl

      public long getTtl()
      获取对象存活时长,即超时总时长,0表示无限
      Returns:
      对象存活时长
    • getExpiredTime

      public Date getExpiredTime()
      获取过期时间,返回null表示永不过期
      Returns:
      此对象的过期时间,返回null表示永不过期
    • getLastAccess

      public long getLastAccess()
      获取上次访问时间
      Returns:
      上次访问时间
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isExpired

      protected boolean isExpired()
      判断是否过期
      Returns:
      是否过期
    • get

      protected V get(boolean isUpdateLastAccess)
      获取值
      Parameters:
      isUpdateLastAccess - 是否更新最后访问时间
      Returns:
      获得对象