Interface Cache<K,V>

Type Parameters:
K - 鍵的型別
V - 值的型別
All Known Implementing Classes:
DualLayerCache, EhcacheCacheAdapter, ManagedCache

public interface Cache<K,V>

快取介面

定義快取的核心操作,包含基本的讀寫、管理功能與狀態查詢。

Since:
1.0
  • Method Details

    • get

      V get(K key)
      取得快取值
      Parameters:
      key - 鍵
      Returns:
      快取值,若不存在或快取已停用則返回 null
    • put

      void put(K key, V value)
      寫入快取
      Parameters:
      key - 鍵
      value - 值
    • remove

      void remove(K key)
      移除快取項目
      Parameters:
      key - 鍵
    • clear

      void clear()
      清空所有快取項目
    • containsKey

      boolean containsKey(K key)
      檢查快取是否包含指定鍵
      Parameters:
      key - 鍵
      Returns:
      true 若包含該鍵
    • disable

      void disable()

      停用快取

      停用後:

      • get() 操作返回 null
      • put() 操作被忽略
      • 已存在的資料保留
      • 可透過 enable() 重新啟用
    • enable

      void enable()
      啟用快取
    • isEnabled

      boolean isEnabled()
      檢查快取是否已啟用
      Returns:
      true 若快取已啟用
    • getStatistics

      CacheStatistics getStatistics()
      取得快取統計資訊
      Returns:
      統計資訊
    • getStatus

      CacheStatus getStatus()
      取得快取狀態
      Returns:
      狀態資訊
    • getName

      String getName()
      取得快取名稱
      Returns:
      快取名稱
    • getConfiguration

      CacheConfiguration<K,V> getConfiguration()
      取得快取配置
      Returns:
      配置資訊