Share via


caches Element

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

The caches element is a container element for cache elements you can use to configure CacheManager Object object-based caches in the application. The cache configuration supports a number of default configurations for advertising, discounts, and other common Commerce Server caches. In each case, the cache type has its own default options associated with it; however, you can override the default options.

The caches element contains two elements: cache and config.

cache Element

The cache element indicates the beginning of a new cache definition in the Web.config file. Depending on the extended configuration settings (config elements) requirements, you can use this element as a container and as a marker element. At least one cache element is required.

The following table lists and describes the attributes of the cache element.

Attribute

Data Type

Description

name

String

The name of the cache.

This attribute is required.

type

String

The type of cache you want to configure. Valid values are:

  • Advertising

  • Custom

  • Discounts

  • MarketingDiscounts

  • OrdersConfiguration

  • Payment

  • Shipping

  • Tax

If you specify one of the valid cache types, Commerce Server provides default values for all attributes. The default value type is "Custom".

This attribute is optional.

loaderProgId

String

The COM ProgID of the object used for seeding the cache.

This attribute is required if the cache type is set to Custom. Otherwise, it is optional.

writerProgId

String

The COM ProgID of the object used for writing cache changes to an external source.

This attribute is optional.

cacheObjectProgId

String

Specifies the object to use as transient storage for cached data. The default value is "Commerce.Dictionary".

This attribute is optional.

refreshInterval

String

The number of seconds until the cache expires and the loader is invoked to refill the cache.

The value of this attribute must represent an integer. The default value is zero (0).

This attribute is optional.

retryInterval

String

The number of seconds the cache manager will wait before attempting to refill the cache if an error is encountered.

The value of this attribute must represent an integer. The default value is 60.

This attribute is optional.

maxSize

String

The maximum size, in bytes, of the cache.

You should specify this attribute only when the value of the type attribute is "Custom".

The value of the CacheSize key of the cache configuration dictionary is set to the value of this attribute. The cache loader component uses this value as specified by the loaderProgId attribute.

The value of this attribute must represent an integer.

This attribute is optional.

config Element

The config element identifies the arbitrary key/value pairs in the cache configuration dictionary. The cache configuration dictionary created by the runtime is supplied to both the loader and writer components, and is used as both the LoaderConfig and WriterConfig dictionaries. If a cache has both loader and writer components and wants to provide a distinct configuration, you must do it programmatically by accessing the CommerceCache instance in the CommerceCacheCollection created for the site. The config element is optional.

If you need to set values for data types other than string, you must set them programmatically.

The following table lists and describes the attributes of the config element.

Attribute

Data Type

Description

key

String

A key name to set as part of the cache configuration.

This attribute is required.

value

String

The value for the specified key.

This attribute is required.

Cache Types

If you specify a known type for the type attribute, Commerce Server provides a set of default values for the configuration. You can override these default values programmatically or you can set the values in the configuration itself.

Some of the cache types have a dependency on a specific Commerce Server resource. When the CommerceCacheModule creates the caches it also runs checks to make sure that all resource dependencies are satisfied. If these dependences are not satisfied, a CommerceResourceDependencyException is generated. If the BizData Service (Profiles) resource does not exist, setting the type to Advertising or Discounts generates a CommerceResourceDependencyException when the application is initialized. Similarly, if the Marketing resource does not exist, setting the type to MarketingDiscounts generates the same exception.

The following tables list the default values for each configuration setting and each type of cache.

Advertising

The Advertising cache has a dependency on the Marketing resource.

Attribute

Value

loaderProgId

Commerce.CSFLoadAdvertisements

writerProgId

Commerce.CSFWriteEvents

refreshInterval

300

retryInterval

60

Custom

Attribute

Value

loaderProgId

None

writerProgId

None

refreshInterval

300

retryInterval

60

Discounts

The Discounts cache has a dependency on the Marketing resource.

Attribute

Value

loaderProgId

Commerce.CSFLoadDiscounts

writerProgId

Commerce.CSFWriteEvents

refreshInterval

0

retryInterval

60

OrdersConfiguration

The Orders cache has a dependency on the Transaction Config resource.

Attribute

Value

loaderProgId

Commerce.OrdersConfigurationCache

writerProgId

None

refreshInterval

0

retryInterval

60

Payment

The Payment cache has a dependency on the Transaction Config resource.

Attribute

Value

loaderProgId

Commerce.PaymentMethodCache

writerProgId

None

refreshInterval

0

retryInterval

60

Shipping

The Shipping cache has a dependency on the Transaction Config resource.

Attribute

Value

loaderProgId

Commerce.ShippingManagerCache

writerProgId

None

refreshInterval

0

retryInterval

60

Tax

The Tax cache has a dependency on the Transaction Config resource.

Attribute

Value

loaderProgId

Commerce.SampleRegionalTaxCache

writerProgId

None

refreshInterval

0

retryInterval

60

Examples

Code

The following code example shows basic configurations for all Commerce Server caches.

<caches>
    <cache 
       name="Advertising" 
       type="Advertising" 
       refreshInterval="900" 
       retryInterval="30"
    />
    <cache 
       name="Discounts" 
       type="Discounts" 
       refreshInterval="0" 
       retryInterval="30"
    />
    <cache 
       name="ShippingManagerCache" 
       type="Shipping" 
       loaderProgId="Commerce.ShippingMethodCache" 
       refreshInterval="0" 
       retryInterval="30"
    />
    <cache name="PaymentMethodCache" type="Payment"/>
    <cache name="OrdersConfigurationCache" type="OrdersConfiguration"/>
</caches>

Code

The following code example shows how to configure the Discounts cache, and the Advertising cache, to write performance data to the WriteEvents pipeline component. The CSFWriteEvents component is used to write the values from the performance dictionary into the mktg_performance_total table in the marketing database. This is done each time a CSF Cache (of type Adverstising or Discounts) is flushed or reloaded. The mktg_spUpdatePerformanceTotal SQL stored procedure is used by default to perform this operation.

Note

To provide extended post-flush processing, create a custom SQL stored procedure in the marketing database, and update the value attribute of the config element with the name of the new procedure. Use the mktg_spUpdatePerformanceTotal stored procedure as a starting point when creating the custom stored procedure.

    <cache name="discounts"
      type="Discounts"
      loaderProgId="Commerce.CSFLoadDiscounts"
      writerProgId="Commerce.CSFWriteEvents"
      refreshInterval="0"
      retryInterval="60">
      <config key="recordEventProcedure" value="mktg_spUpdatePerformanceTotal" />
    </cache>
    <cache name="advertising"
      type="Advertising"
      loaderProgId="Commerce.CSFLoadAdvertising"
      writerProgId="Commerce.CSFWriteEvents"
      refreshInterval="0"
      retryInterval="60">
      <config key="recordEventProcedure" value="mktg_spUpdatePerformanceTotal" />
    </cache>

See Also

Reference

CommerceCache

CommerceCacheModule

Other Resources

ShippingManagerCache

Web.Config Configuration Settings