Eksportér (0) Udskriv
Udvid alt
EN
Dette indhold er ikke tilgængeligt på dit sprog, men her er den engelske version.

Configuration Model (In-Role Cache for Azure Cache)

Updated: September 24, 2014

noteNote
For guidance on choosing the right Azure Cache offering for your application, see Which Azure Cache offering is right for me?.

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

  1. Role Configuration

  2. Client Configuration

Role Configuration

In-Role Cache supports the ability to host caching within a 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 In-Role Cache. 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 In-Role Cache, 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 In-Role Cache 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 In-Role Cache 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 In-Role Cache Role Configuration Settings (ServiceConfiguration.cscfg).

Client Configuration

A cache client is any application code that accesses a 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 In-Role Cache.

<?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 In-Role Cache Client Configuration Settings (Web.config). For a walkthrough that shows how to configure clients of role-based In-Role Cache, see How To: Use Azure SDK In-Role Cache.

See Also

Fællesskabsindhold

Tilføj
Vis:
© 2014 Microsoft