Commerce Engine Connect caching
Commerce Engine (CE) Connect caching stores catalog entities to allow for quicker access from the storefront. The size of Commerce catalogs and the complexity of their structure can affect memory cache behavior.
The Sitecore XC solution supports two Commerce Engine Connect cache providers:
-
Redis - the Redis cache provider is for distributed deployments, including integration, testing, and production environments. By default, Commerce Engine Connect uses Redis caching.
-
Memory - in-memory caching is for single-server deployments and development environments only.
Commerce Engine Connect distributed caching
In a distributed Commerce deployment, Commerce Engine (CE) Connect uses Redis for caching catalog entities for improving the performance of the Content Delivery (CD) and Content Management (CM) environments. A single instance of Redis can contain cache stores for both CE Connect caching and Commerce Engine caching. The CE Connect cache store uses DB0. The Commerce Engine cache store uses DB1.
CE Connect Caching configuration
You can change the CE Connect caching service provider or fine-tune the caching configuration to meet the requirements of your Commerce storefront. The CE Connect Cache settings are located in the c:\inetpub\wwwroot\<site>\App_Config\Include\Y.Commerce.Engine
folder, in the Sitecore.Commerce.Engine.Connect.config
file.
The Redis cache provider is enabled by default in CE Connect caching configuration. If you enable both Redis and the in-memory cache providers, or if you disable both, CE Connect uses in-memory caching.
The following shows an example of the Redis cache configuration in the Sitecore.Commerce.Engine.Connect.config
file:
<!-- Redis cache provider configuration --> <commerceCachingConfiguration type="Sitecore.Commerce.Engine.Connect.CommerceCachingConfiguration,Sitecore.Commerce.Engine.Connect.Caching">
<cachingSettings type="Sitecore.Commerce.Engine.Connect.CachingSettings, Sitecore.Commerce.Engine.Connect.Caching">
<redis type="Sitecore.Commerce.Engine.Connect.RedisCacheSettings, Sitecore.Commerce.Engine.Connect.Caching">
<enabled>true</enabled>
<cacheStoreName>Commerce-Connector-Redis</cacheStoreName>
<intervalBetweenConnectionAttemptsInSeconds>60</intervalBetweenConnectionAttemptsInSeconds>
<redisConnectionPoolSize>1</redisConnectionPoolSize>
<redisCompressionEnabled>true</redisCompressionEnabled>
<options type="Sitecore.Commerce.Engine.Connect.CommerceRedisCacheOptions, Sitecore.Commerce.Engine.Connect.Caching"> <configuration>localhost:6379,defaultDatabase=1,allowAdmin=true,syncTimeout=3600000</configuration>
<instanceName>Redis</instanceName>
</options>
</redis>
<memory type="Sitecore.Commerce.Engine.Connect.MemoryCacheSettings, Sitecore.Commerce.Engine.Connect.Caching">
<enabled>false</enabled>
<cacheStoreName>Commerce-Connector-Memory</cacheStoreName>
</memory>
<cacheEntry type="Sitecore.Commerce.Engine.Connect.CacheEntrySettings, Sitecore.Commerce.Engine.Connect.Caching"> <cacheName>CommerceConnect</cacheName>
<expiration>21600000</expiration>
</cacheEntry>
</cachingSettings>
</commerceCachingConfiguration>
Redis provider parameters
You can use the following parameters to configure the Redis cache provider:
Parameter |
Description |
---|---|
|
Specifies whether the provider is enabled. Default value: |
|
Sets the name of the cache store. Default value: |
|
Sets the number of seconds before a failed connection attempts to connect again. Default value: |
|
The number of connection to Redis in a pool. Default value: |
|
Controls whether the Redis provider compresses cached data. Default value: |
|
Specifies the connection string options for the Redis cache provider. The following are defaults:
|
|
Sets the Redis instance name. Default value: |
In-memory cache provider parameters
You can use the following parameters to configure the in-memory cache provider:
Parameter |
Description |
---|---|
|
Specifies whether the provider is enabled. Default value: |
|
Sets the name of the cache store. Default value: |
|
Sets the threshold at which the cache removes the least recently used entries to make room for new entries. Default value: |
|
Sets the maximum size in bytes permitted in the cache store. Default value: |
|
Sets the maximum time after which the cache store updates its memory statistics. Default value: |
|
Sets the maximum number of items for a cache store. If no value is specified there is no limit and limitation is based on maximum size allowed in cache (as determined by the |
|
Sets the minimum length of time between scans for expired items. Default value: |
|
Sets the percentage of cache data to compact when the maximum size is exceeded. Default value: |
Cache Entry configuration
You can use the following parameters to configure cache entries (for any cache provider):
Parameter |
Description |
---|---|
|
Specifies the name of the cache. |
|
Sets the length of time after which a cache entry expires, in milliseconds. The default is 21600000. |
|
Sets the priority for the cache entry. Possible values are:
|
|
Sets the length of time after which a cache entry expires relative to the current timestamp, in milliseconds. |
|
Sets the length of time after which a cache entry expires if it has not been accessed, in milliseconds. |
Threshold triggering full cache refresh after incremental indexing
The incremental indexing process runs at a regular interval and indexes any new or modified Commerce items. When the quantity of new or modified items exceeds the threshold specified by the <fullCacheRefreshThreshold>
property value, then a full cache refresh is executed. The following shows the default configuration:
<!-- Threshold that triggers a full cache refresh after incremental indexing --> <fullCacheRefreshThreshold>20</fullCacheRefreshThreshold>
CE Connect Cache maintenance
You can refresh the content of the CE Connect cache in Sitecore Content Editor. (You cannot use the caching API sample requests in Postman to maintain the CE Connect cache.)
To refresh the CE Connect cache:
-
On the Sitecore Launchpad, click Content Editor.
-
On the Commerce tab, click Refresh Commerce Cache.
The Refresh Commerce Cache operation refreshes the following caches:
-
Sitecore item cache
-
Content path cache
-
Sitecore data cache
-
Standard value cache
-
Template cache
-
Template engine cache
-
HTML cache
-
Catalog entities
-
Catalog mappings (always cached in memory)