Adding Redis connection options to Commerce caching configurations

Abstract

How to add Redis connection options to Commerce Engine and CE Connect caching configurations.

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 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 Redis configuration options in the Sitecore.Commerce.Engine.Connect.config file on the Sitecore instance. The path to the file is: wwwroot\<SitecoreInstance>\App_Config\Include\Y.Commerce.Engine\Sitecore.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:

  "Redis":  {
      "Enabled":  true,
      "CacheStoreName":  "Commerce-Redis-Store",
          "Options":  {
                    "Configuration":  "localhost:6379,password:PASSWORD"
                    }

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

<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:6379,defaultDatabase=1,allowAdmin=true,syncTimeout=3600000,password=PASSWORD</configuration>
        <instanceName>Redis</instanceName>
      </options>
</redis>