Class CacheConfig

java.lang.Object
springboot.bg.harisauto.common.config.cache.CacheConfig

@Configuration @EnableCaching public class CacheConfig extends Object
CacheConfig.java - In-process caching for the service catalogue.

The catalogue is read on almost every page and changes only when an administrator edits it, so it is the one thing here worth caching. Writes evict explicitly, so a change made on the admin page is visible immediately; the time limit is only a backstop against a stale entry outliving a restart of a sibling instance.

Author:
Kristian Popov
  • Field Details

  • Constructor Details

    • CacheConfig

      public CacheConfig()
  • Method Details

    • cacheManager

      @Bean public org.springframework.cache.CacheManager cacheManager()
      Builds the cache manager.

      Caffeine keeps this in-process. That suits a single instance; running more than one would need a shared cache, which is why the eviction below is explicit rather than relying on expiry alone.

      Returns:
      The configured cache manager.