Reference data caching

Abstract

Overview of the settings involved in the caching of reference data.

Caching is controlled by the following section of the C:\path\to\reference\data\App_data\config\sitecore\ReferenceData\sc.XConnect.ReferenceData.Service.Cache.xml file:

   <ReferenceData.Service.Cache.MemoryDefinitionCache>
       <!-- Cache implementation which stores entries in memory. -->
       <Type>Sitecore.Xdb.ReferenceData.Service.Cache.MemoryDefinitionCache, Sitecore.Xdb.ReferenceData.Service</Type>
       <As>Sitecore.Xdb.ReferenceData.Core.Cache.IDefinitionCache, Sitecore.Xdb.ReferenceData.Core</As>
       <LifeTime>Singleton</LifeTime>
       <Options>
       <!-- The lifetime of entries in the cache. Default value: 20 seconds. -->
       <EntryLifetime>00:00:20</EntryLifetime>
       </Options>
   </ReferenceData.Service.Cache.MemoryDefinitionCache>

These settings apply if you are using accessing the Reference Data Service over HTTPS using the :code:`ReferenceDataHttpClient` implementation of :code:`IReferenceDataClient`. To disable caching, replace the cache type with :code:`NullDefinitionCache`:
<ReferenceData.Service.Cache.MemoryDefinitionCache>
    <!-- Cache implementation which stores entries in memory. -->
    <Type>Sitecore.Xdb.ReferenceData.Service.Cache.NullDefinitionCache, Sitecore.Xdb.ReferenceData.Service</Type>
    <As>Sitecore.Xdb.ReferenceData.Core.Cache.IDefinitionCache, Sitecore.Xdb.ReferenceData.Core</As>
    <LifeTime>Singleton</LifeTime>
</ReferenceData.Service.Cache.MemoryDefinitionCache>

Note

If you are accessing the Reference Data Service from a Sitecore server that uses the ReferenceDataService implementation of IReferenceDataClient, caching client configuration applies.

Configuring the Reference Data Service in a Sitecore context

Some core roles, such as Processing, access the Reference Data Service database directly via the service API rather than the client API. In a Sitecore context, the Reference Data Service caching options are configured in the C:\path\to\sitecore\App_Config\Sitecore\Marketing.Xdb.ReferenceData.Service\Sitecore.Xdb.ReferenceData.Service.config file.

The following settings determine the cache implementation and cache entry lifetime:

<xdb.referenceData.service>
  <definitionCache type="Sitecore.Xdb.ReferenceData.Service.Cache.MemoryDefinitionCache, Sitecore.Xdb.ReferenceData.Service">
    <!-- entryLifetime: The lifetime of entries in the cache, given as a TimeSpan -->
    <param name="entryLifetime">00:00:30</param>
  </definitionCache>
</xdb.referenceData.service>

To disable caching, replace the cache type with NullDefinitionCache as shown:

<xdb.referenceData.service>
  <definitionCache type="Sitecore.Xdb.ReferenceData.Service.Cache.NullDefinitionCache, Sitecore.Xdb.ReferenceData.Service">
    <!-- entryLifetime: The lifetime of entries in the cache, given as a TimeSpan -->
    <param name="entryLifetime">00:00:30</param>
  </definitionCache>
</xdb.referenceData.service>