Class AssetCaffeineAutoConfiguration

java.lang.Object
com.broadleafcommerce.asset.autoconfigure.AssetCaffeineAutoConfiguration

@Configuration @Conditional(com.broadleafcommerce.common.extension.cache.condition.OnEnabledCacheCondition.class) @ConditionalOnClass(org.springframework.cache.caffeine.CaffeineCacheManager.class) @ConditionalOnProperty(value="com.broadleafcommerce.cache.activeCacheManagerImplementation", havingValue="com.broadleafcommerce.common.extension.cache.caffeine.CaffeineAutoConfiguration") @AutoConfigureAfter(com.broadleafcommerce.common.extension.cache.caffeine.CaffeineAutoConfiguration.class) @EnableConfigurationProperties({AssetCacheProperties.class,AssetCacheWeightProperties.class}) public class AssetCaffeineAutoConfiguration extends Object
Auto-configuration for asset caching using Caffeine as the underlying cache implementation. This configuration is activated based on the following conditions: - The application cache setting (`spring.cache.type`) is not explicitly disabled (`NONE`). - The `JCacheCacheManager` is available on the classpath. - The specific cache manager implementation for Broadleaf Commerce, `com.broadleafcommerce.common.extension.cache.caffeine.CaffeineAutoConfiguration`, is set as active (`com.broadleafcommerce.cache.activeCacheManagerImplementation` property is configured or defaulted). It also binds to and utilizes externalized configuration properties from `AssetCacheProperties`. Primary features provided by this configuration include: - Customization of a `CaffeineCacheManager` using a budget manager to configure heap and off-heap memory budgets for caches related to the asset service. - Pre-configures two primary caches: - `CACHE_BY_URL`: For caching assets by URLs with its TTL and budget proportion controlled via `byUrlTtl` and the budget distribution settings in `AssetCacheProperties`. - `CACHE_BY_PROVIDER_TYPE_AND_OG_LOCATION`: For caching assets based on provider type and original location, with its TTL and budget governed via the nested `StorageLocationMappingCacheProperties`. - Allows the injection of a custom `CacheManagerCustomizer` (`assetCaffeineManagerCustomizer`) should the default implementation be absent.
  • Constructor Details

    • AssetCaffeineAutoConfiguration

      public AssetCaffeineAutoConfiguration()
  • Method Details

    • assetCaffeineManagerCustomizer

      @Bean @ConditionalOnMissingBean(name="assetCaffeineManagerCustomizer") public org.springframework.boot.autoconfigure.cache.CacheManagerCustomizer<org.springframework.cache.caffeine.CaffeineCacheManager> assetCaffeineManagerCustomizer(com.broadleafcommerce.common.extension.cache.caffeine.CaffeineBudgetManager budgetManager, AssetCacheProperties props, AssetCacheWeightProperties weightProps)