Caching
Describes how caching is used in Optimizely Commerce Connect for product catalogs and entries.
Platform cache functionality, including remote sync, is part of the Optimizely platform.
Classes in this topic are in the Mediachase.Commerce.Catalog namespace.
Cache subsystems
Configure caching options for each subsystem, such as catalogs and orders, using either AppSettings.json or the ConfigureServices method of the Startup class.
The following example shows Cache settings for the Catalogs subsystem, using AppSettings.json:
"EPiServer": {
"Commerce": {
"CatalogOptions": {
"Cache": {
"UseCache": true,
"ContentVersionCacheExpiration": "00:05:00",
"CollectionCacheExpiration": "00:05:00",
"EntryCacheExpiration": "00:05:00",
"NodeCacheExpiration": "00:05:00"
}
}
}
}The following example shows Cache settings for the Catalogs subsystem, using Startup:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CatalogOptions>(o =>
{
o.Cache.UseCache = true;
o.Cache.ContentVersionCacheExpiration = TimeSpan.FromMinutes(05);
o.Cache.CollectionCacheExpiration = TimeSpan.FromMinutes(05);
o.Cache.EntryCacheExpiration = TimeSpan.FromMinutes(05);
o.Cache.NodeCacheExpiration = TimeSpan.FromMinutes(05);
});
}The CollectionCacheExpiration responds to an entry array, and "entry" responds to a single entry. What is actually cached is the CatalogEntryDto and, because the Entry object is created from the Data Transfer Object (DTO), you cache the DTO. In some cases, you can also cache the entry objects themselves rather than the DTO.
Cache invalidation
In the Catalogs subsystem example, the cache is invalidated if it reaches the cache timeout specified previously (00:05:00) for the request type, or if an object is updated. You can also invalidate cache for the entire catalog by calling CatalogCache.Clear().
Related topics
Updated 12 days ago
