General Purpose Programming Concepts

The following objects are considered general purpose, and can be used in many contexts within Commerce Server:

  • AdminEventLog Object

  • AdminFiles Object

  • CacheManager Object

  • Dictionary Object

  • GenID Object

  • LRUCache Object

  • SimpleList Object

AdminEventLog Object

The AdminEventLog object is used to write error, informational, and warning messages to the event log, which can be viewed in the Commerce Server Manager Event Viewer snap-in.

For more information, see AdminEventLog Object.

AdminFiles Object

The AdminFiles object is used to return the contents of a file on the server. The file contents can be of any type, such as text, bitmaps, numeric data, and so on.

For more information, see AdminFiles Object.

CacheManager Object

The CacheManager object is normally created in the Application_OnStart event in the Global.asa file for an Active Server Pages (ASP) application. It uses the services of other Component Object Model (COM) objects called Loader and Writer components, whose job it is to populate caches with data and write data that has been collected in the cache, respectively. Each cache is required to have a Loader component configured, but the Writer component is optional. The CacheManager object is configured by setting the LoaderProgId, LoaderConfig, WriterProgId, and WriterConfig properties for each cache being created.

After one or more caches have been configured in an application, any ASP page in the application can use the GetCache method of the CacheManager object to access the cached data. The type of cache object returned, either a Dictionary object or an LRUCache object, depends on the configuration of the LoaderProgId property for the cache.

The CacheManager object can be configured to automatically refresh each cache periodically, based on the RefreshInterval property. Automatic cache refresh can also be disabled by setting the RefreshInterval property to zero (0), which is the default. The CacheManager object also retries failed load operations after a configurable pause, controlled with the RetryInterval property.

When the CacheManager object refreshes the cache, either from an explicit call to the RefreshCache method or based on the refresh interval expiring, it performs several actions. First, if the cache has been configured with a Writer component, the CacheManager object creates, configures, and executes the Writer component to record performance data collected since the last refresh operation. If the Writer component should fail, then the entire refresh operation is aborted. Next, the CacheManager object creates, configures, and executes the specified Loader component to repopulate the cache. A Loader component can be designed such that if it determines that the existing contents of the cache are current, or otherwise sufficient, it can simply return CACHE_E_NOCACHE_UPDATED message. When the CacheManager object recognizes this return code, it does not replace the existing cache with the newly created one that was passed to the Loader component, and any changes that were made to the new cache object are discarded.

For more information, see CacheManager Object.

Dictionary Object

A Commerce Server Dictionary object is a collection object that supports the creation, storage, and retrieval of key/value pairs in memory. Every element in a Dictionary object is a Variant, which means you can create a Dictionary object that consists of almost any kind of values (including other Dictionary objects), and that you can store any combination of Variant types in the same Dictionary object.

The Commerce Server architecture uses the Dictionary object for a number of specialized purposes, including the SiteConfig object. However, because a Dictionary object is designed to be a general purpose collection, you can use it for almost anything that its internal structure supports.

For more information, see Dictionary Object.

GenID Object

This object is used to generate globally unique identifiers (GUIDs).

For more information, see GenID Object.

LRUCache Object

This object is used to support the creation, storage, and retrieval of key/value pairs from a cache. LRUCache objects are similar to Dictionary objects, except that LRUCache objects can only store a limited number of elements. The LRUCache object ranks elements from most-recently-used to least-recently-used. When the LRUCache object is at capacity, it removes the least-recently-used element from the cache and adds the new element. The replacement algorithm used by LRUCache object is an approximate method that allows the cache size to grow to 110 percent of its maximum size setting. Once this limit is reached, the least-recently-used 10 percent of items are removed from the cache.

For more information, see LRUCache Object.

SimpleList Object

A Commerce Server SimpleList object consists of an array of Variants that supports enumeration and access by index. The SimpleList object is used extensively throughout Commerce Server. Use a SimpleList object instead of a Dictionary object in circumstances where accessing the stored content by index is important.

For more information, see SimpleList Object.


All rights reserved.