Class XanthicSpringCacheManager

java.lang.Object
io.github.xanthic.cache.spring.XanthicSpringCacheManager
All Implemented Interfaces:
org.springframework.cache.CacheManager

public class XanthicSpringCacheManager
extends java.lang.Object
implements org.springframework.cache.CacheManager
CacheManager implementation that lazily builds XanthicCache instances for each getCache(java.lang.String) request. Also supports a 'static' mode where the set of cache names is pre-defined through cacheNames in the constructor, with no dynamic creation of further cache regions at runtime. The configuration of the underlying cache can be fine-tuned through the CacheApiSpec, passed into this CacheManager in the constructor.
  • Constructor Summary

    Constructors 
    Constructor Description
    XanthicSpringCacheManager​(java.util.function.Consumer<io.github.xanthic.cache.core.CacheApiSpec<java.lang.Object,​java.lang.Object>> spec)
    XanthicSpringCacheManager will manage all xanthic cache instances for spring.
    XanthicSpringCacheManager​(java.util.function.Consumer<io.github.xanthic.cache.core.CacheApiSpec<java.lang.Object,​java.lang.Object>> spec, java.util.Collection<java.lang.String> cacheNames)
    XanthicSpringCacheManager will manage all xanthic cache instances for spring.
  • Method Summary

    Modifier and Type Method Description
    org.springframework.cache.Cache getCache​(@NotNull java.lang.String name)  
    @NotNull java.util.Collection<java.lang.String> getCacheNames()  
    java.util.Set<java.lang.String> getCustomCacheNames()  
    void registerCache​(java.lang.String name, java.util.function.Consumer<io.github.xanthic.cache.core.CacheApiSpec<java.lang.Object,​java.lang.Object>> spec)
    Register a custom xanthic cache by customizing the CacheApiSpec.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XanthicSpringCacheManager

      public XanthicSpringCacheManager​(java.util.function.Consumer<io.github.xanthic.cache.core.CacheApiSpec<java.lang.Object,​java.lang.Object>> spec)
      XanthicSpringCacheManager will manage all xanthic cache instances for spring.
      Parameters:
      spec - the default CacheApiSpec used to create a new cache instances
    • XanthicSpringCacheManager

      public XanthicSpringCacheManager​(java.util.function.Consumer<io.github.xanthic.cache.core.CacheApiSpec<java.lang.Object,​java.lang.Object>> spec, @Nullable java.util.Collection<java.lang.String> cacheNames)
      XanthicSpringCacheManager will manage all xanthic cache instances for spring.
      Parameters:
      spec - the default CacheApiSpec used to create a new cache instances
      cacheNames - If not null, the number of caches and their names will be fixed, with no creation of further cache keys at runtime.
  • Method Details

    • getCache

      @Nullable public org.springframework.cache.Cache getCache​(@NotNull @NotNull java.lang.String name)
      Specified by:
      getCache in interface org.springframework.cache.CacheManager
    • getCacheNames

      @NotNull public @NotNull java.util.Collection<java.lang.String> getCacheNames()
      Specified by:
      getCacheNames in interface org.springframework.cache.CacheManager
    • registerCache

      public void registerCache​(java.lang.String name, java.util.function.Consumer<io.github.xanthic.cache.core.CacheApiSpec<java.lang.Object,​java.lang.Object>> spec)
      Register a custom xanthic cache by customizing the CacheApiSpec.
      Parameters:
      name - the name of the cache
      spec - configuration for the specified cache
    • getCustomCacheNames

      public java.util.Set<java.lang.String> getCustomCacheNames()