@Component(value="blSparsePriceListOverrideStrategy") public class SparsePriceListOverrideStrategy extends Object implements PriceListOverrideStrategy, org.broadleafcommerce.common.cache.OverridePreCacheInitializer
ThresholdCachePriceListOverrideStrategy,
this strategy opts for completely caching overrides and minimizing template queries. The highest template query optimization
is achieved in conjunction with the 'precached.sparse.override.template.search.restrict.catalog' property set to true (false by
default). See com.broadleafcommerce.tenant.service.extension.MultiTenantTemplateOnlyQueryExtensionHandler for more information,
since this setting assumes the sku entity is in the same catalog as the SkuPriceData instance, which may
not be true for all installations.
Hybrid configurations are also possible for small to medium size template SkuPriceData catalogs where the threshold
count bounding queries are not a concern and complete (or partial) caching of the template catalog can be achieved. However,
such a strategy may provide little to no benefit over the out-of-the-box ThresholdCachePriceListOverrideStrategy.
See the templateEnabled property for more information.
This strategy also works best when there are few standard sites with isolated values (i.e. the value was created in the standard
site and was not inherited from a profile or catalog). This is because the strategy can utilize an optimized template
query that is portable across sites if it doesn't have to take into account the standard site. The strategy uses
OverridePreCacheService.isActiveIsolatedSiteForType(Long, String) to figure out this state.
This strategy is disabled by default. Please see the javadoc for com.broadleafcommerce.tenant.service.cache.SparseOverridePreCacheServiceImpl (MultiTenant only)
for more information on how to enable this strategy via configuration of that service.ThresholdCachePriceListOverrideStrategy| Modifier and Type | Field and Description |
|---|---|
protected javax.persistence.EntityManager |
em |
protected org.broadleafcommerce.common.extension.TemplateOnlyQueryExtensionManager |
extensionManager |
static int |
PRECACHED_SPARSE_OVERRIDE_ORDER |
protected org.broadleafcommerce.common.cache.OverridePreCacheService |
preCachedSparseOverrideService |
protected com.broadleafcommerce.enterprise.common.extension.pricelist.PriceListDaoExtensionManager |
priceListExtensionManager |
protected PriceListSupport |
priceListSupport |
protected boolean |
restrictAssociation
Whether or not to restrict the template search to the catalog of an associated item.
|
protected boolean |
templateEnabled
Whether or not
getTemplate(String, PriceList, Sku)
will be utilized from this strategy. |
| Constructor and Description |
|---|
SparsePriceListOverrideStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected org.broadleafcommerce.common.extension.StandardCacheItem |
buildSingleItemResponse(SkuPriceData priceData) |
protected String |
getCacheKey(Long priceListId,
Long skuId) |
protected Long |
getNormalizedId(Object testObject) |
int |
getOrder() |
org.broadleafcommerce.common.extension.StandardCacheItem |
getOverride(PriceList priceList,
org.broadleafcommerce.core.catalog.domain.Sku sku,
String basicCacheKey)
Retrieve the standard site override SkuPriceData, if applicable
|
org.broadleafcommerce.common.extension.StandardCacheItem |
getTemplate(String templateCacheKey,
PriceList priceList,
org.broadleafcommerce.core.catalog.domain.Sku sku)
Retrieve the template level SkuPriceData, if applicable
|
protected SkuPriceData |
getTemplateSkuPriceData(PriceList priceList,
org.broadleafcommerce.core.catalog.domain.Sku sku) |
org.broadleafcommerce.common.extension.StandardCacheItem |
initializeOverride(Object entity) |
boolean |
isOverrideQualified(Class<?> type) |
boolean |
isRestrictAssociation() |
void |
setRestrictAssociation(boolean restrictAssociation) |
boolean |
validateTemplateProcessing(String standardCacheKey,
String templateCacheKey)
Whether or not a template version should be searched for.
|
public static final int PRECACHED_SPARSE_OVERRIDE_ORDER
protected org.broadleafcommerce.common.cache.OverridePreCacheService preCachedSparseOverrideService
protected org.broadleafcommerce.common.extension.TemplateOnlyQueryExtensionManager extensionManager
protected javax.persistence.EntityManager em
@Autowired protected PriceListSupport priceListSupport
@Value(value="${precached.sparse.override.pricelist.template.enabled:true}")
protected boolean templateEnabled
getTemplate(String, PriceList, Sku)
will be utilized from this strategy. If false, the fallback
ThresholdCachePriceListOverrideStrategy.getTemplate(String, PriceList, Sku)
will be used instead.
If the 'template' repository (MT concept) is large, this value should be left true. However, if the 'template' repository
is relatively small, you may want to consider setting this to false in order to leverage the possibility of complete
caching in the default strategy. See PriceListSupport.getThresholdForFullCache() for more info on this
option.
The default value is true. Set the 'precached.sparse.override.pricelist.template.enabled' property to change the value.
This value is meaningless if the current standard site is found to contain active isolated values for SkuPriceData.
Review the documentation in com.broadleafcommerce.tenant.service.cache.SparseOverridePreCacheServiceImpl for more information.@Value(value="${precached.sparse.override.pricelist.template.search.restrict.association:false}")
protected boolean restrictAssociation
protected com.broadleafcommerce.enterprise.common.extension.pricelist.PriceListDaoExtensionManager priceListExtensionManager
public org.broadleafcommerce.common.extension.StandardCacheItem getOverride(PriceList priceList, org.broadleafcommerce.core.catalog.domain.Sku sku, String basicCacheKey)
PriceListOverrideStrategygetOverride in interface PriceListOverrideStrategypublic org.broadleafcommerce.common.extension.StandardCacheItem getTemplate(String templateCacheKey, PriceList priceList, org.broadleafcommerce.core.catalog.domain.Sku sku)
PriceListOverrideStrategygetTemplate in interface PriceListOverrideStrategypublic int getOrder()
getOrder in interface org.springframework.core.Orderedpublic boolean isOverrideQualified(Class<?> type)
isOverrideQualified in interface org.broadleafcommerce.common.cache.OverridePreCacheInitializerpublic org.broadleafcommerce.common.extension.StandardCacheItem initializeOverride(Object entity)
initializeOverride in interface org.broadleafcommerce.common.cache.OverridePreCacheInitializerpublic boolean validateTemplateProcessing(String standardCacheKey, String templateCacheKey)
PriceListOverrideStrategyvalidateTemplateProcessing in interface PriceListOverrideStrategypublic boolean isRestrictAssociation()
public void setRestrictAssociation(boolean restrictAssociation)
protected SkuPriceData getTemplateSkuPriceData(PriceList priceList, org.broadleafcommerce.core.catalog.domain.Sku sku)
protected org.broadleafcommerce.common.extension.StandardCacheItem buildSingleItemResponse(SkuPriceData priceData)
Copyright © 2018. All rights reserved.