Class DefaultCacheController

  • All Implemented Interfaces:
    CacheController

    public class DefaultCacheController
    extends java.lang.Object
    implements CacheController
    Main point connecting platform with cache.
    Class is responsible for:
    • Cache configuration: gathers cache regions, region resolvers and invalidation filters in one place.
    • Resolves cache region using resolvers.
    • Processes adding from cache.
    • Processes invalidating cache units.
    • Decides whether using cache registry or not.
    • Constructor Detail

      • DefaultCacheController

        public DefaultCacheController​(@Qualifier("cacheConfiguration")
                                      CacheConfiguration configuration)
    • Method Detail

      • init

        @PostConstruct
        public void init()
        Reads configuration and creates registry for cache regions required
      • invalidate

        public void invalidate​(CacheKey key)
        Performs key invalidation from cache.
        Method checks invalidation filters and cache registry.
        Specified by:
        invalidate in interface CacheController
      • remove

        public void remove​(CacheKey key)
        Legacy method implemented just to implement lazy computing in AbstractCacheUnit
        Specified by:
        remove in interface CacheController
      • get

        public <T> T get​(CacheKey key)
        Description copied from interface: CacheController
        Gets value stored in the cache. If value is not already loaded returns NULL.
        Specified by:
        get in interface CacheController
      • resolveQueryRegionsForInvalidation

        public java.util.Collection<CacheRegion> resolveQueryRegionsForInvalidation​(CacheKey key)
        returns all regions handling queries. There may be more than one region handling queries.
      • resolveRegionsForInvalidation

        public java.util.List<CacheRegion> resolveRegionsForInvalidation​(CacheKey key)
        Returns cache regions for invalidation.
        Only regions which can store key provided.
      • resolveCacheRegionForAdd

        public CacheRegion resolveCacheRegionForAdd​(CacheKey key)
                                             throws CacheRegionNotSpecifiedException
        Method used to resolve cache region.
        Resolved cache region can be used as a parameter to invalidate() and getOrAdd().
        It can improve performance when many operations are performed.
        Parameter regionName should be stored in transaction (or other) context.
        If the forInvalidation flag is set and no region name specified region proxy can be returned. This region proxy invalidates given key in all defined cache region.
        Throws:
        CacheRegionNotSpecifiedException
      • getLifecycleCallbackCnt

        public int getLifecycleCallbackCnt()
        For testing only
      • executeOnAfterAddCallbacks

        protected void executeOnAfterAddCallbacks​(CacheKey key,
                                                  java.lang.Object value,
                                                  CacheRegion region)
      • executeOnAfterRemoveCallbacks

        protected void executeOnAfterRemoveCallbacks​(CacheKey key,
                                                     java.lang.Object value,
                                                     CacheRegion region)
      • executeOnEvictionCallbacks

        protected void executeOnEvictionCallbacks​(CacheKey key,
                                                  java.lang.Object value,
                                                  CacheRegion region)
      • executeOnMissLoadCallbacks

        protected void executeOnMissLoadCallbacks​(CacheKey key,
                                                  java.lang.Object value,
                                                  CacheRegion region)
      • setStatsEnabled

        public void setStatsEnabled​(boolean enabled)
        Description copied from interface: CacheController
        Allows to enable or disable collecting of statistics for all regions in one step. Collection of cache statistics has negative impact on cache performance.
        Specified by:
        setStatsEnabled in interface CacheController
      • registerTenant

        @Deprecated
        public void registerTenant​(java.lang.String tenantId)
        Deprecated.
        since 5.0
        Description copied from interface: CacheController
        Setups registry for tenant
        Specified by:
        registerTenant in interface CacheController
      • setCacheRegionProvider

        public void setCacheRegionProvider​(CacheRegionProvider cacheRegionProvider)
        Spring initialization
      • setRegionRegistryAllocationStrategy

        @Deprecated
        public void setRegionRegistryAllocationStrategy​(RegionRegistryAllocationStrategy regionRegistryAllocationStrategy)
        Deprecated.
        since 5.0
      • setGenerationalCacheDelegate

        public void setGenerationalCacheDelegate​(GenerationalCacheDelegate generationalCacheDelegate)
      • unwrap

        @Deprecated
        public CacheController unwrap()
        Deprecated.
        since 5.0