Interface CacheManager

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
EhcacheCacheManager

public interface CacheManager extends AutoCloseable

快取管理器介面

負責快取的生命週期管理,包含建立、取得、移除快取等操作。

Since:
1.0
  • Method Details

    • createCache

      <K,V> Cache<K,V> createCache(CacheConfiguration<K,V> configuration)
      建立快取
      Type Parameters:
      K - 鍵的型別
      V - 值的型別
      Parameters:
      configuration - 快取配置
      Returns:
      快取實例
      Throws:
      IllegalStateException - 若快取已存在
    • getCache

      <K,V> Cache<K,V> getCache(String name, Class<K> keyType, Class<V> valueType)
      取得快取
      Type Parameters:
      K - 鍵的型別
      V - 值的型別
      Parameters:
      name - 快取名稱
      keyType - 鍵的型別
      valueType - 值的型別
      Returns:
      快取實例,若不存在則返回 null
    • removeCache

      void removeCache(String name)
      移除快取
      Parameters:
      name - 快取名稱
    • getCacheNames

      Collection<String> getCacheNames()
      取得所有快取名稱
      Returns:
      快取名稱集合
    • hasCache

      boolean hasCache(String name)
      檢查快取是否存在
      Parameters:
      name - 快取名稱
      Returns:
      true 若快取存在
    • close

      void close()
      關閉管理器,釋放所有資源
      Specified by:
      close in interface AutoCloseable