Class LoomCacheManager

java.lang.Object
com.loomcache.springboot.cache.LoomCacheManager
All Implemented Interfaces:
org.springframework.cache.CacheManager

public final class LoomCacheManager extends Object implements org.springframework.cache.CacheManager
Spring CacheManager implementation backed by LoomCache.

Lazily creates LoomSpringCache instances on demand and caches them locally in a ConcurrentHashMap for thread-safe access. The eagerCacheNames list is used to pre-create caches up front so that Spring configuration surfaced via loomcache.spring-cache.cache-names actually takes effect at application startup instead of waiting for the first getCache(String) call.

Since:
1.0
See Also:
  • Constructor Details

    • LoomCacheManager

      public LoomCacheManager(LoomCache loomClient)
      Convenience constructor without eager cache names.
      Parameters:
      loomClient - the LoomCache client used for all distributed cache operations
      Throws:
      NullPointerException - if loomClient is null
    • LoomCacheManager

      public LoomCacheManager(LoomCache loomClient, List<String> eagerCacheNames)
      Construct a new LoomCacheManager with the supplied eager cache names propagated from Spring properties.
      Parameters:
      loomClient - LoomCache client
      eagerCacheNames - cache names to create up front at construction time
      Throws:
      NullPointerException - if loomClient or eagerCacheNames is null
      IllegalArgumentException - if any eager cache name is null or blank
    • LoomCacheManager

      public LoomCacheManager(LoomCache loomClient, List<String> eagerCacheNames, Duration defaultTtl)
  • Method Details

    • getCache

      public org.springframework.cache.Cache getCache(String name)
      Specified by:
      getCache in interface org.springframework.cache.CacheManager
    • getCacheNames

      public Collection<String> getCacheNames()
      Specified by:
      getCacheNames in interface org.springframework.cache.CacheManager