Azure Managed Cache Service の ASP.NET ページ出力キャッシュ プロバイダー構成設定
重要
Microsoft では、すべての新しい開発で Azure Redis Cache を使用することをお勧めします。 Azure Cache オファリングの選択に関する最新のドキュメントとガイダンスについては、「自分に適した Azure Cache オファリング」を参照してください。
このトピックでは、ASP.NET 用の Azure Managed Cache Service 出力キャッシュ プロバイダーの構成設定について説明します。 これらの設定は、web.config ファイルの outputCache 要素の providers セクションで指定します。
出力キャッシュ構成の設定
属性 | [説明] |
---|---|
name (必須) |
プロバイダーを参照するために outputCache 要素によって使用されるプロバイダーの "フレンドリ" 名。 |
type (必須) |
プロバイダーの .NET Framework 型文字列。 必要な値については、後述の注を参照してください。 |
cacheName (必須) |
Azure キャッシュの名前。 これは、 |
dataCacheClientName (省略可能) |
dataCacheClients 構成セクションから使用する dataCacheClient セクションの名前。 この属性は、web.config ファイルに複数の dataCacheClient セクションが指定されている場合にのみ必要です。 既定では、プロバイダーは dataCacheClient という名前 |
applicationName (省略可能) |
出力キャッシュ データを保存するためにキャッシュ キーを作成するときに、プロバイダーが使用する文字列値。 既定値は空の文字列です。 この属性が設定されていない場合、プロバイダーは内部で使用するキャッシュ キーの一部として HttpRuntime.AppDomainAppId の値を使用します。 セッション状態機能とは異なり、通常は複数の ASP.NET アプリケーションで出力キャッシュ データを共有しません (たとえば、/contoso と /AdventureWorks は出力キャッシュ データを共有できません)。 共有するのではなく、同じアプリケーションの複数の物理インスタンスが、いずれも同じ出力キャッシュ データにアクセスできるようにします。 この場合、2 つの実行方法があります。
|
retryInterval (省略可能) |
キャッシュと通信するときにエラーが発生した場合、再試行の間に待機する時間。 この値に使用する文字列の形式は |
retryCount (省略可能) |
キャッシュとの通信エラーが発生したときに、プロバイダーに再試行回数を通知する整数値。 ただし、再試行できない操作もあります。 再試行回数の既定値は 3 です。 プロバイダーは、各再試行の間に構成された retryInterval 時間をスリープ状態にします。 |
注意
type 属性は ..“Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache”
例
<!-- Non-cache sections omitted for space -->
<configuration>
<configSections>
<section name="dataCacheClients"
type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core"
allowLocation="true"
allowDefinition="Everywhere" />
<section name="cacheDiagnostics"
type="Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsConfigurationSection, Microsoft.ApplicationServer.Caching.AzureCommon"
allowLocation="true"
allowDefinition="Everywhere" />
</configSections>
<system.web>
<!-- Azure Caching output caching provider -->
<!--Uncomment this section to use Azure Caching for output caching-->
<caching>
<outputCache defaultProvider="AFCacheOutputCacheProvider">
<providers>
<add name="AFCacheOutputCacheProvider"
type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache"
cacheName="default"
dataCacheClientName="default"
applicationName="AFCacheOutputCache" />
</providers>
</outputCache>
</caching>
</system.web>
<dataCacheClients>
<dataCacheClient name="default">
<!--To use the in-role flavor of Azure Caching, set identifier to be the cache cluster role name -->
<!--To use the Azure Caching Service, set identifier to be the endpoint of the cache cluster -->
<autoDiscover
isEnabled="true"
identifier="[Cache role name or Service Endpoint]" />
<!--<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />-->
<!--Use this section to specify security settings for connecting to your cache.
This section is not required if your cache is hosted on a role that is a part
of your cloud service. -->
<!--<securityProperties mode="Message" sslEnabled="false">
<messageSecurity authorizationInfo="[Authentication Key]" />
</securityProperties>-->
</dataCacheClient>
<cacheDiagnostics>
<crashDump dumpLevel="Off" dumpStorageQuotaInMB="100" />
</cacheDiagnostics>
</dataCacheClients>
</configuration>
注意
cacheDiagnostics
セクションは、Cache NuGet パッケージから ASP.NET Web ロール クライアントに対してのみ追加されます。 詳細については、「Azure Managed Cache Service の ClientDiagnosticLevel について」を参照してください。