Entering Configuration Information

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

These procedures explain how to configure the Caching Application Block. Properties associated with the nodes appear in the right pane of the Configuration Console or in the Properties window of the Visual Studio Configuration Editor.

If you are going to use the Data Access Application Block as the backing store, you must configure that application block before you configure the Caching Application Block.

For details of the schema for the Caching Application Block configuration, see Source Schema for the Caching Application Block.

To add the Caching Application Block

  1. Open the configuration file. For more information, see Configuring Enterprise Library.
  2. Right-click Application Configuration, point to New, and then click Caching Application Block.
  3. The configuration tool automatically adds the Cache Manager node with default settings.

To configure the cache manager

  1. Click the Caching Application Block node.
  2. (Optional) Change the DefaultCacheManager property name. The default cache manager is used if the code does not specify a cache manager. Either enter a new name or select one from the drop-down list. The default name is CacheManager.
  3. Click the CacheManager node (if you renamed the cache manager, the node will have the name you assigned it).
  4. (Optional) Set the ExpirationPollFrequencyInSeconds property. This is the frequency of the timer that regulates how often the background scheduler checks for expired items. The unit is seconds; the minimum time is 1 second, and the default setting is 60 seconds.
  5. Set the MaximumElementsInCacheBeforeScavenging property. This is the maximum number of elements that can be in the cache before scavenging. The default setting is 1000 elements.
  6. (Optional) Rename the CacheManager node. The default name is CacheManager.
  7. Set the NumberToRemoveWhenScavenging property. This is the number of elements to remove after scavenging begins. The default setting is 10 elements.

By default, the cache stores items only in memory and assigns the value of the backing store to NullBackingStore. You can also configure the Caching Application Block to use database cache storage, isolated storage, or custom cache storage. Database cache storage uses the Data Access Application Block.

To configure the Caching Application Block for database cache storage

  1. Right-click CacheManager (if you renamed the cache manager, the node will have the name you assigned it), point to New, and then click DatabaseCacheStorage.
  2. The configuration tool automatically adds the Data Access Application Block. For information about configuring this application block, see The Data Access Application Block documentation.
  3. Click the DataCacheStorage node.
  4. Set the DatabaseInstance property. This is the name of the database connection string. It must correspond to the name of a connection string in the Data Access Application Block configuration. Either enter the name or select it from the drop-down list.
  5. (Optional) Set the Name property by renaming the DataCacheStorage node.
  6. Set the PartitionName property. This identifies the portion of the database that the cache manager will use.

To configure the Caching Application Block for isolated storage

  1. Right-click CacheManager (if you renamed the cache manager, the node will have the name you assigned it), point to New, and then click IsolatedStorage.
  2. If you want to encrypt the information stored in isolated storage, right-click Isolated Storage, point to New, and click Symmetric Storage Encryption. The configuration tool automatically adds the Cryptography Application Block. For information about configuring this application block, see The Cryptography Application Block documentation.
  3. (Optional) Set the Name property by renaming the IsolatedStorage node.
  4. Set the PartitionName property. This identifies the portion of isolated storage that the cache manager will use.

To configure the Caching Application Block for custom cache storage

  1. Right-click CacheManager (if you renamed the cache manager, the node will have the name you assigned it), point to New, and then click Custom CacheStorage.
  2. In the Attributes property section of the right pane, click the ellipsis button (...).
  3. In the EditableKeyValueCollectionEditor dialog box, click Add to add a new name/value pair.
  4. In the right pane of the EditableKeyValueCollectionEditor dialog box, enter the key name and the value of the property.
  5. Add more name/value pairs as appropriate, and then click OK.
  6. (Optional) In the Name section of the configuration properties, change the name of the custom cache storage. The default name is CacheStorage.
  7. In the Type property section of the right pane, click the ellipsis button. To filter the list, in the Filter edit box type the string to use to filter the list, for example type "string" to filter for all classes containing the word "string". If the type you want is not included in the Assemblies folder, click Load from File or Load from GAC on the TypeSelector to find the assembly that contains the type you want.

If you want to add another instance of the cache manager, right-click the CacheManagers node, point to New, and then click CacheManager. Repeat the preceding procedures. There can be only one default cache manager. Each instance of the cache manager must have a unique name.

Usage Notes

The configuration settings for the Caching Application Block should reflect both an application's caching usage pattern and its system environment, such as the amount of available memory. For example, if an application adds items to the cache at a greater rate than it removes them when scavenging (this is a configurable setting), the cache will continue grow. Over time, this can cause memory starvation. Use the application block's performance counters to help tune the configuration settings for each application.