Class ManagedCache<K,V>

java.lang.Object
io.leandev.appfuse.cache.core.ManagedCache<K,V>
Type Parameters:
K - 鍵的型別
V - 值的型別
All Implemented Interfaces:
Cache<K,V>

public class ManagedCache<K,V> extends Object implements Cache<K,V>

可管理的快取

包裝底層快取,提供停用、清除、狀態查詢等管理功能。

Since:
1.0
  • Constructor Details

  • Method Details

    • get

      public V get(K key)
      Description copied from interface: Cache
      取得快取值
      Specified by:
      get in interface Cache<K,V>
      Parameters:
      key - 鍵
      Returns:
      快取值,若不存在或快取已停用則返回 null
    • put

      public void put(K key, V value)
      Description copied from interface: Cache
      寫入快取
      Specified by:
      put in interface Cache<K,V>
      Parameters:
      key - 鍵
      value - 值
    • remove

      public void remove(K key)
      Description copied from interface: Cache
      移除快取項目
      Specified by:
      remove in interface Cache<K,V>
      Parameters:
      key - 鍵
    • clear

      public void clear()
      Description copied from interface: Cache
      清空所有快取項目
      Specified by:
      clear in interface Cache<K,V>
    • containsKey

      public boolean containsKey(K key)
      Description copied from interface: Cache
      檢查快取是否包含指定鍵
      Specified by:
      containsKey in interface Cache<K,V>
      Parameters:
      key - 鍵
      Returns:
      true 若包含該鍵
    • disable

      public void disable()
      Description copied from interface: Cache

      停用快取

      停用後:

      • get() 操作返回 null
      • put() 操作被忽略
      • 已存在的資料保留
      • 可透過 enable() 重新啟用
      Specified by:
      disable in interface Cache<K,V>
    • enable

      public void enable()
      Description copied from interface: Cache
      啟用快取
      Specified by:
      enable in interface Cache<K,V>
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: Cache
      檢查快取是否已啟用
      Specified by:
      isEnabled in interface Cache<K,V>
      Returns:
      true 若快取已啟用
    • getStatistics

      public CacheStatistics getStatistics()
      Description copied from interface: Cache
      取得快取統計資訊
      Specified by:
      getStatistics in interface Cache<K,V>
      Returns:
      統計資訊
    • getStatus

      public CacheStatus getStatus()
      Description copied from interface: Cache
      取得快取狀態
      Specified by:
      getStatus in interface Cache<K,V>
      Returns:
      狀態資訊
    • getName

      public String getName()
      Description copied from interface: Cache
      取得快取名稱
      Specified by:
      getName in interface Cache<K,V>
      Returns:
      快取名稱
    • getConfiguration

      public CacheConfiguration<K,V> getConfiguration()
      Description copied from interface: Cache
      取得快取配置
      Specified by:
      getConfiguration in interface Cache<K,V>
      Returns:
      配置資訊
    • getDelegate

      public Cache<K,V> getDelegate()
      取得底層快取(供進階使用)
      Returns:
      底層快取