Package de.hybris.platform.regioncache
Class DefaultCacheController
- java.lang.Object
-
- de.hybris.platform.regioncache.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 Summary
Constructors Constructor Description DefaultCacheController(CacheConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddLifecycleCallback(CacheLifecycleCallback callback)registers a lifecycle callback.voidclearCache(CacheRegion region)Clears cacheprotected voidexecuteOnAfterAddCallbacks(CacheKey key, java.lang.Object value, CacheRegion region)protected voidexecuteOnAfterRemoveCallbacks(CacheKey key, java.lang.Object value, CacheRegion region)protected voidexecuteOnEvictionCallbacks(CacheKey key, java.lang.Object value, CacheRegion region)protected voidexecuteOnMissLoadCallbacks(CacheKey key, java.lang.Object value, CacheRegion region)<T> Tget(CacheKey key)Gets value stored in the cache.java.util.List<InvalidationFilter>getFilters()intgetLifecycleCallbackCnt()For testing onlyjava.util.List<CacheRegion>getRegions()Returns all regions used in this controller.CacheRegionResolver[]getResolvers()<T> TgetWithLoader(CacheKey key, CacheValueLoader<T> loader)Gets stored value from cache.voidinit()Reads configuration and creates registry for cache regions requiredvoidinvalidate(CacheKey key)Performs key invalidation from cache.voidregisterTenant(java.lang.String tenantId)Deprecated.since 5.0voidremove(CacheKey key)Legacy method implemented just to implement lazy computing in AbstractCacheUnitvoidremoveLifecycleCallback(CacheLifecycleCallback callback)Removes a registered lifecycle callback.CacheRegionresolveCacheRegionForAdd(CacheKey key)Method used to resolve cache region.java.util.Collection<CacheRegion>resolveQueryRegionsForInvalidation(CacheKey key)returns all regions handling queries.java.util.List<CacheRegion>resolveRegionsForInvalidation(CacheKey key)Returns cache regions for invalidation.voidsetCacheRegionProvider(CacheRegionProvider cacheRegionProvider)Spring initializationvoidsetGenerationalCacheDelegate(GenerationalCacheDelegate generationalCacheDelegate)voidsetRegionRegistryAllocationStrategy(RegionRegistryAllocationStrategy regionRegistryAllocationStrategy)Deprecated.since 5.0voidsetStatsEnabled(boolean enabled)Allows to enable or disable collecting of statistics for all regions in one step.CacheControllerunwrap()Deprecated.since 5.0
-
-
-
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:
invalidatein interfaceCacheController
-
remove
public void remove(CacheKey key)
Legacy method implemented just to implement lazy computing in AbstractCacheUnit- Specified by:
removein interfaceCacheController
-
getWithLoader
public <T> T getWithLoader(CacheKey key, CacheValueLoader<T> loader) throws CacheValueLoadException
Gets stored value from cache. If value is not available loader is invoked.- Specified by:
getWithLoaderin interfaceCacheController- Throws:
CacheRegionNotSpecifiedExceptionCacheValueLoadException
-
get
public <T> T get(CacheKey key)
Description copied from interface:CacheControllerGets value stored in the cache. If value is not already loaded returns NULL.- Specified by:
getin interfaceCacheController
-
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
-
getResolvers
public CacheRegionResolver[] getResolvers()
- Returns:
- the resolvers
-
getFilters
public java.util.List<InvalidationFilter> getFilters()
-
getRegions
public java.util.List<CacheRegion> getRegions()
Description copied from interface:CacheControllerReturns all regions used in this controller.- Specified by:
getRegionsin interfaceCacheController
-
clearCache
public void clearCache(CacheRegion region)
Clears cache- Specified by:
clearCachein interfaceCacheController
-
addLifecycleCallback
public void addLifecycleCallback(CacheLifecycleCallback callback)
Description copied from interface:CacheControllerregisters a lifecycle callback. Callbacks are executed in order of registration.- Specified by:
addLifecycleCallbackin interfaceCacheController
-
removeLifecycleCallback
public void removeLifecycleCallback(CacheLifecycleCallback callback)
Description copied from interface:CacheControllerRemoves a registered lifecycle callback.- Specified by:
removeLifecycleCallbackin interfaceCacheController
-
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:CacheControllerAllows 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:
setStatsEnabledin interfaceCacheController
-
registerTenant
@Deprecated public void registerTenant(java.lang.String tenantId)
Deprecated.since 5.0Description copied from interface:CacheControllerSetups registry for tenant- Specified by:
registerTenantin interfaceCacheController
-
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
-
-