Partager via


Caching in the Catalog System

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

To prevent repeated calls to SQL Server, the catalog system caches the results of various methods in the form of datasets. The catalog system uses the System.Web.Caching.Cache object to cache the various datasets. Each dataset is inserted in the cache with the CacheItemPriority.Normal property value. The dataset remains in the cache for a configurable period of time. If not specified, the default time is five minutes.

To account for the relative frequency at which different items in the catalog system are changed, the datasets are classified into six different categories. This categorization enables you to specify different time-outs. The goal is to enable items that change less frequently to remain in the cache much longer that items that change more frequently.

Configuration

You can define cache configuration when you create the CatalogContext object, as in the following example.

CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.CacheEnabled = true;
cacheConfiguration.SchemaCacheTimeout = new TimeSpan(0, 10, 0);
cacheConfiguration.ItemAssociationsCacheTimeout = new TimeSpan(0, 10, 0);
cacheConfiguration.ItemHierarchyCacheTimeout = new TimeSpan(0, 10, 0);
cacheConfiguration.ItemInformationCacheTimeout = new TimeSpan(0, 10, 0);
cacheConfiguration.ItemRelationshipsCacheTimeout = new TimeSpan(0, 10, 0);
cacheConfiguration.CatalogCollectionCacheTimeout = new TimeSpan(0, 10, 0);
CatalogSiteAgent siteAgent = new CatalogSiteAgent();
siteAgent.SiteName = "SiteName";
CatalogContext cc = CatalogContext.Create(siteAgent, cacheConfiguration);

You enable caching by setting the CacheEnabled property on the CacheConfiguration object to true.

Dataset Categories

The following sections describe the different categories of datasets and their time-out configuration parameters.

Catalog Schema

The catalog schema category applies to datasets that return schema information. These datasets remain in the cache for the duration defined by the SchemaCacheTimeout property on the CacheConfiguration object. Because the catalog schema is unlikely to change after it has been defined, setting the SchemaCacheTimeout property to a high value can result in improved performance.

The SchemaCacheTimeout property applies to the datasets returned by the following properties and methods:

Item Properties

Most of the objects in the catalog system expose an Information property, which is a dataset that contains the properties for that object. For example, the Information property on the ProductCatalog object returns a dataset that contains the properties of the specified product catalog. The duration that the dataset returned by the Information property remains in the cache is controlled by the ItemInformationCacheTimeout property on the CacheConfiguration object.

The ItemInformationCacheTimeout property applies to the datasets returned by the Information properties on the following types:

This time-out also applies to the datasets returned by the DataRow property on the Variant object and to the product information that is stored by the QueryCatalogInfo pipeline component.

If inventory integration is enabled, the inventory information is also cached.

Catalog Hierarchy

The catalog system lets you define parent-child hierarchies between categories and products. This information is returned in the form of datasets. The duration for which these datasets are cached is determined by the ItemHierarchyCacheTimeout property on the CacheConfiguration object. The ItemHierarchyCacheTimeout property applies to the following methods and properties:

Catalog Relationships

The catalog system lets you define relationships between products and categories. The duration for which the relationships datasets remain in the cache is determined by the ItemRelationshipsCacheTimeout property on the CacheConfiguration object. It applies to the following properties:

Associations Between Different Objects

The catalog system lets you specify various types of associations between different objects. For example, product catalogs are associated with inventory catalogs, product catalogs are associated with catalog sets, and languages are associated with product catalogs. The duration for which these association datasets remain in the cache is determined by the ItemAssociationsCacheTimeout property on the CacheConfiguration object. It applies to the datasets returned by the following properties and methods:

Catalog Collections

The CatalogCollectionCacheTimeout property on the CacheConfiguration object controls how long the datasets returned from the following methods remain in the cache:

Monitoring the Catalog Cache

If you enable caching, you can monitor the performance of the cache by observing the following performance counters.

Performance counter

Description

CacheTotalHits

The total number of cache hits.

CacheTotalMissess

The total number of cache misses.

CacheHitRate

The number of cache hits per second.

CacheMissRate

The number of cache misses per second.

CacheHitRatio

The ratio of cache hits to the total number of cache accesses. This number is equal to CacheTotalHits / (CacheTotalHits + CacheTotalMisses).

CacheTurnOverRate

The number of cache insertions and deletions per second.

See Also

Other Resources

Performance Considerations in the Catalog System