Work with Ucommerce Caching
Ucommerce uses NHibernate and NHibernate Cache.
NHibernate has a 1st level cache per session (always in memory) and a 2nd level cache per factory (provider based).
Ucommerce uses the NHibernate 2nd level Cache for some entities, look at the list below. Ucommerce uses the NHibernate Query cache for some queries, look at the list below.
By default, Ucommerce uses NHibernate SysCache, but this can be changed to another provider if needed. Since SysCache uses the ASP.NET Cache, changing the ASP.NET Cache Provider is also a possibility to change to another cache store.
Ucommerce has 5 distinct cache regions defined.
- CatalogFoundation
- MarketingFoundation
- TransactionFoundation
- SecurityFoundation
- Backend
How to clear the cache
Clearing the whole cache can be done with the ICacheProvider
Ucommerce.EntitiesV2.ICacheProvider
Description
Provides functionality for managing caching.
Methods
ClearCache
-
Arguments
- This method is called without any arguments
- Return type
Void
Ucommerce.EntitiesV2.ICacheProvider.ClearCache
- Return type
Void
Calling the API
var cacheProvider = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<Ucommerce.EntitiesV2.ICacheProvider>(); cacheProvider.ClearCache();
How to set the timeout for the cache regions
In web.config the timeout of the different regions can be set.
<syscache> <!-- Cache catalog objects for 60 mins before refreshing --> <cache region="CatalogFoundation" expiration="3600" priority="5"/> <cache region="MarketingFoundation" expiration="3600" priority="5"/> <cache region="SecurityFoundation" expiration="3600" priority="5"/> <cache region="Backend" expiration="3600" priority="5"/> </syscache>
How to turn off the cache
The NHibernate Cache can be disabled in web.config
<commerce> <runtimeConfiguration enableCache="false" ... </commerce>
This should only be used for troubleshooting and can have severe impact on performance.
What entities do Ucommerce cache in the 2nd level cache?
Note! No Order entities are cached.
CatalogFoundation
- Category
- CategoryProductRelation
- CategoryProperty
- Currency
- DataTypeEnumDescription
- DataTypeEnum
- DataType
- DefinitionField
- DefinitionMap
- DefinitionTypeDescription
- DefinitionType
- PriceGroup
- ProductCatalogGroup
- ProductCatalog
- ProductDefinitionFieldDescription
- ProductDefinition
- ProductDescription
- ProductDescriptionProperty
- Product
- ProductProperty
- ProductRelation
- ProductRelationType
- ProductReviewComment
- ProductReview
- ProductReviewStatus
MarketingFoundation
- CampaignItem
- CampaignItemProperty
- Campaign
- Target
TransactionFoundation
- Country
- DefinitionFieldDescription
- EmailContent
- EmailParameter
- EmailProfileInformation
- EmailProfile
- EmailType
- OrderStatus
- PaymentMethodDescription
- PaymentMethod
- PaymentStatus
- ShippingMethodDescription
- ShippingMethod
- ShippingMethodPrice
SecurityFoundation
- Role
- UserGroup
- User
Backend
- AdminPage
- AdminTab
- EntityUiDescription
- EntityUi
What Queries do Ucommerce cache in the Query Cache?
Note! No Order queries are cached.
CatalogFoundation
- TabsForPageQuery
- AllCategoriesForCatalogQuery
- AllCategoriesQuery
- AllProductDefinitionsQuery
- AllProductsQuery
- AllProductTreeViewQuery
- AllProductVariantTreeViewQuery
- CategoriesInCatalogQuery
- CategoriesInCategoryQuery
- CategoryDefinitionIdQuery
- CategoryTreeViewByCategoryIdsQuery
- CategoryTreeViewQuery
- ChildCategoryQuery
- FullProductDefinitionsQuery
- MultipleProductQuery
- ProductCatalogGroupViewByProductCatalogGroupIdsQuery
- ProductDefinitionIdQuery
- ProductsInCategoryQuery
- ProductTreeViewQuery
- ProductVariantTreeViewQuery
- ProductViewByProductIdsQuery
- ProductViewFromParentProductIdsQuery
- ProductViewInCategoryQuery
- RootCategoriesInCatalogQuery
- SingleCategoryQuery
- ProductCatalogGroupTargetCatalogGroupsQuery
- ProductTargetProductsQuery
- OrderStatusQuery
MarketingFoundation
- CampaignItemTreeViewByCategoryIdsQuery
- ActiveCampaignItemsQuery
- AllApplyTargetsForCampaignItemQuery
- AllAwardsForCampaignItemQuery
- AllTargetsForCampaignItemQuery
- AllVoucherCodesForVoucherTargetQuery
TransactionFoundation
- DefinitionTreeViewByCategoryIdsQuery
- SingleBasketQuery
- SingleOrderQuery
SecurityFoundation
- AllRolesQuery