Commerce Engine Connect caching

Version: 9.3

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.

Diagram showing Commerce Engine Connect distributed caching in Content Delivery and Content Management environments using Redis.

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.

Note

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.

RequestResponse
//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>
    <options
type="Microsoft.Extensions.Caching.Redis.RedisCacheOptions,
Microsoft.Extensions.Caching.Redis">
    <configuration>localhost,defaultDatabase=1,allowAdmin=true</configuration>
    <instanceName>Redis</instanceName>
    </options>
  </redis>
//In-memory cache provider configuration//       
<memory type="Sitecore.Commerce.Engine.Connect.MemoryCacheSettings,
Sitecore.Commerce.Engine.Connect.Caching">
    <enabled>false</enabled>
    <cacheStoreName>Commerce-Connector-Memory</cacheStoreName>
  </memory>
//Cache entry configuration// 
 <cacheEntry
type="Sitecore.Commerce.Engine.Connect.CacheEntrySettings,
Sitecore.Commerce.Engine.Connect.Caching">         
      <cacheName>CommerceConnect</cacheName>
      <expiration>21600000</expiration>
    </cacheEntry>
  /cachingSettings>
</commerceCachingConfiguration>

Cache provider parameters

You can configure the following parameters for your cache provider:

Provider

Parameter

Description

Redis

enabled

Specifies whether the provider is enabled.

Default: true.

cacheStoreName

Sets the name of the cache store.

configuration

Specifies the connection string for the Redis cache provider, for example, localhost.

Default: localhost.

allowAdmin=True

The allowAdmin=true configuration setting is required to perform flush cache operations.

defaultDatabase

Specifies the default database.

Important

If other applications share the same Redis service, you must specify the defaultDatabase setting, so that CE Connect flush cache operations do not affect other applications.

instanceName

Sets the Redis instance name.

Memory

enabled

Specifies whether the provider is enabled.

Default: false.

cacheStoreName

Sets the name of the cache store.

evictionPercentage

Sets the threshold at which the cache removes the least recently used entries to make room for new entries.

Default: 0.2

maxSizeInBytes

Sets the maximum size in bytes permitted in the cache store.

Default: 9223372036854775807 (long.MaxValue)

pollingInterval

Sets the maximum time after which the cache store updates its memory statistics.

Default: 00:02:00 (2 minutes).

sizeLimit

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.

expirationScanFrequency

Sets the minimum length of time between scans for expired items.

Default: "00:01:00" (1 minute)

compactionPercentage

Sets the percentage, expressed as a decimal, of cache data to compact when the maximum size is exceeded.

Default: 0.05

Cache Entry configuration

You can configure the following parameters for cache entries (for any cache provider):

Parameter

Description

cacheName

Specifies the name of the cache.

expiration

Sets the length of time after which a cache entry expires, in milliseconds. The default is 21600000.

priority

Sets the priority for the cache entry. Possible values are:

  • Low

  • Normal

  • High

  • NeverRemove

absoluteExpirationRelativeToNow

Sets the length of time after which a cache entry expires relative to the current timestamp, in milliseconds.

slidingExpiration

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:

RequestResponse
<!-- 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:

  1. On the Sitecore Launchpad, click Content Editor.

  2. 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)

Do you have some feedback for us?

If you have suggestions for improving this article,