Adding Redis connection options to Commerce caching configurations

Version: 10.3

You can add Redis configuration options to the Redis connection settings specified in the Commerce Engine caching and Commerce Engine (CE) Connect caching configurations.

For Commerce Engine caching, you add Redis configuration options directly in the Commerce Engine config.json file. The path to the file is: wwwroot\<CommerceEngine>\wwwroot\config.json.

For Commerce Engine connect caching, you add your custom Redis configuration options in the Custom.Commerce.Engine.Connect.config patch file on the Sitecore instance. The path to the file is: wwwroot\<SitecoreInstance>\App_Config\Include\Y.Commerce.Engine\CustomCommerce\Custom.Commerce.Engine.Connect.config.

Example: Add a Redis password property to the caching configuration

In the following examples, the connection to the Redis cache provider requires authentication. As a result, the Commerce Engine and Commerce Engine Connect configurations are updated to include the required password property and appropriate value.

The following shows an example of the Redis configuration in the Commerce Engine config.json file:

RequestResponse
  "Redis":  {
      "Enabled":  true,
      "CacheStoreName":  "Commerce-Redis-Store",
      "IntervalBetweenConnectionAttemptsInSeconds":  60,
      "RedisConnectionPoolSize":  1,
      "RedisCompressionEnabled":  true,
          "Options":  {
                     "Configuration":  "localhost:6379,password=PASSWORD"
                      }

The following shows an example of the "CacheSettings" section in the default Sitecore.Commerce.Engine.Connect.config file:

Important

Do not make configuration changes directly in the Sitecore.Commerce.Engine.Connect.config file. To customize CE Connect configuration, use the Custom.Commerce.Engine.Connect.config patch file, or create your own patch file.

RequestResponse
<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="Microsoft.Extensions.Caching.Redis.RedisCacheOptions, Microsoft.Extensions.Caching.Redis">
       <configuration>localhost:6379,defaultDatabase=1,allowAdmin=true,syncTimeout=3600000,password=PASSWORD</configuration>
       <instanceName>Redis</instanceName>
      </options>
</redis>

Do you have some feedback for us?

If you have suggestions for improving this article,