Class EhcacheBudgetManager

java.lang.Object
com.broadleafcommerce.common.extension.cache.ehcache.EhcacheBudgetManager
All Implemented Interfaces:
org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class EhcacheBudgetManager extends Object implements org.springframework.context.SmartLifecycle
Manages memory budgeting and initialization for Ehcache regions across services. This manager allows for adaptive rebalancing of cache weights if additional caches are added (e.g., via extensions).
  • Constructor Details

  • Method Details

    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface org.springframework.context.Phased
      Specified by:
      getPhase in interface org.springframework.context.SmartLifecycle
    • addCache

      public void addCache(String serviceName, String cacheName, Duration ttl, double weightHint, int estimatedSizeHint)
      Registers a cache region with the manager. Initialization is deferred until apply() is called.
      Parameters:
      serviceName - the name of the service (e.g., "catalog")
      cacheName - the name of the cache region
      ttl - the time-to-live duration
      weightHint - the relative weight of this cache region (0.0 to 1.0)
      estimatedSizeHint - the estimated average size of a single cache entry in bytes
    • addService

      public void addService(String serviceName, org.springframework.cache.jcache.JCacheCacheManager cacheManager, int heapBudget, int offHeapBudget)
      Registers a service with the manager. Initialization is deferred until apply() is called.
      Parameters:
      serviceName - the name of the service (e.g., "catalog")
      cacheManager - the JCache cache manager
      heapBudget - the total heap budget in MB for the service
      offHeapBudget - the total off-heap budget in MB for the service
    • apply

      public void apply()
      Calculates the memory distribution and initializes all registered caches for all registered services.