0 out of 1 rated this helpful - Rate this topic

Configuration Model (Windows Azure Caching)

This topic covers the use of configuration files in Windows Azure Caching. There are two types of configuration settings.

  1. Role Configuration

  2. Client Configuration

noteNote
The ability to configure a Windows Azure role for Caching is supported only for role-based Caching.

Role Configuration

Caching supports the ability to host Caching within a Windows Azure role. This type of Caching is configured as part of a cloud service. Typically, this is done in Visual Studio.

noteNote
The configuration settings described in this section apply only to role-based Caching. Shared Caching supports access only to the default cache. Shared Caching does not support altering the properties of the default cache.

To understand the configuration settings, it is helpful to correlate those settings with the user interface options in Visual Studio. The following screenshot shows a portion of the Caching tab on the role properties dialog.

Caching Co-located Properites Window

In addition to enabling Caching, you can also create one or more named caches. Each cache specifies its own properties. The following screenshot shows this portion of the Caching properties tab.

Caching Properties for Named Caches

These user interface selections are stored in configuration files. First, the Caching module is loaded in the Imports section of the ServiceDefinition.csdef file. The following XML snippet shows this line.

<Import moduleName="Caching" />

All other Caching settings are stored in the ServiceConfiguration.cscfg file. For example, here are the settings in the ServiceConfiguration.cscfg file for the previously shown Caching tab selections.

  <Role name="WebRole1">
    <Instances count="2" />
    <ConfigurationSettings>
      <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
      <Setting name="Microsoft.WindowsAzure.Plugins.Caching.NamedCaches" value="{&quot;caches&quot;:[{&quot;name&quot;:&quot;NamedCache1&quot;,&quot;policy&quot;:{&quot;eviction&quot;:{&quot;type&quot;:0},&quot;expiration&quot;:{&quot;defaultTTL&quot;:20,&quot;isExpirable&quot;:true,&quot;type&quot;:2},&quot;serverNotification&quot;:{&quot;isEnabled&quot;:true}},&quot;secondaries&quot;:1},{&quot;name&quot;:&quot;NamedCache2&quot;,&quot;policy&quot;:{&quot;eviction&quot;:{&quot;type&quot;:-1},&quot;expiration&quot;:{&quot;defaultTTL&quot;:25,&quot;isExpirable&quot;:true,&quot;type&quot;:1},&quot;serverNotification&quot;:{&quot;isEnabled&quot;:false}},&quot;secondaries&quot;:0}]}" />
      <Setting name="Microsoft.WindowsAzure.Plugins.Caching.Loglevel" value="" />
      <Setting name="Microsoft.WindowsAzure.Plugins.Caching.CacheSizePercentage" value="30" />
      <Setting name="Microsoft.WindowsAzure.Plugins.Caching.ConfigStoreConnectionString" value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>
  </Role>

In this role configuration, most of the Caching settings have a simple correlation to the options on the Caching tab. However, the Microsoft.WindowsAzure.Plugins.Caching.NamedCaches setting is more difficult to read. It uses JSON syntax to describe the properties of each named cache, and all of the double-quotes are replaced by &quot;. For reference for role configuration settings, see Windows Azure Caching Role Configuration Settings (ServiceConfiguration.cscfg).

Client Configuration

A cache client is any application code that accesses a Windows Azure cache. In code, each cache client is associated with a DataCacheFactory object. The factory returns a DataCache object that is used to access the cache. The actual settings of the cache client can be loaded from an application or web.config configuration file.

The following example demonstrates the relevant sections to setup a dataCacheClient section named default in a configuration file. This is specific to role-based Caching.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />
  </configSections>
  <dataCacheClients>
    <tracing sinkType="DiagnosticSink" traceLevel="Error" />
    <dataCacheClient name="default">
      <autoDiscover isEnabled="true" identifier="WebRole1" />
    </dataCacheClient>
  </dataCacheClients>
</configuration>

For reference for these client configuration settings, see Windows Azure Caching Client Configuration Settings (Web.config). For a walkthrough that shows how to configure clients of role-based Caching, see How To: Use Windows Azure Caching.

For Shared Caching, the autoDiscover element is not used. Shared Caching requires the addition of the hosts and securityProperties elements. This provides information about where the shared cache is located and the security permissions to access it.

<dataCacheClient name="default">
  <hosts>
    <host name="[CACHENAME].cache.windows.net" cachePort="22233" />
  </hosts>

  <securityProperties mode="Message">
    <messageSecurity 
      authorizationInfo="[SECURITYKEY]">
    </messageSecurity>
  </securityProperties>
</dataCacheClient>

For more information on how to use configuration files for Shared Caching, see How to: Configure a Cache Client using the Application Configuration File (Windows Azure Shared Caching).

See Also


Build Date:

2013-01-22
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.