다음을 통해 공유


Azure 역할 내 캐시의 구성 모델

중요

Microsoft는 모든 새 개발에서 Azure Redis Cache를 사용하는 것이 좋습니다. Azure Cache 제품 선택에 대한 현재 설명서 및 지침 은 나에게 적합한 Azure Cache 제품을 참조하세요.

이 항목에서는 Microsoft Azure Cache의 구성 파일 사용에 대해 설명합니다. 구성 설정에는 두 가지 유형이 있습니다.

  1. 역할 구성

  2. 클라이언트 구성

역할 구성

In-Role Cache는 Azure 역할 내에서 캐싱을 호스트하는 기능을 지원합니다. 이러한 유형의 캐싱은 클라우드 서비스의 일부로 구성됩니다. 일반적으로 이 작업은 Visual Studio 수행됩니다.

참고

이 섹션에서 설명하는 구성 설정은 역할 기반 In-Role Cache에만 적용됩니다. Shared Caching 캐시에 default 대한 액세스만 지원합니다. Shared Caching 캐시의 속성 변경은 default 지원하지 않습니다.

구성 설정을 이해하려면 이러한 설정을 Visual Studio 사용자 인터페이스 옵션과 상호 연결하는 것이 좋습니다. 다음 스크린샷에는 역할 속성 대화 상자의 캐싱 탭 중 일부가 나와 있습니다.

Caching Co-located Properites Window

In-Role 캐시를 사용하도록 설정하는 것 외에도 하나 이상의 명명된 캐시를 만들 수도 있습니다. 각 캐시는 자체 속성을 지정합니다. 다음 스크린샷에는 캐싱 속성 탭의 이 부분이 나와 있습니다.

Caching Properties for Named Caches

이러한 사용자 인터페이스 선택 항목은 구성 파일에 저장됩니다. 먼저 캐싱 모듈이 ServiceDefinition.csdef 파일의 Imports 섹션에 로드됩니다. 다음 XML 조각에 이 줄이 나와 있습니다.

<Import moduleName="Caching" />

다른 모든 In-Role 캐시 설정은 ServiceConfiguration.cscfg 파일에 저장됩니다. 예를 들어 다음은 앞서 표시된 캐싱 탭 선택 항목에 대한 ServiceConfiguration.cscfg 파일의 설정입니다.

  <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-Role 캐시 설정은 캐싱 탭의 옵션과 간단한 상관 관계를 갖습니다. 그러나 Microsoft.WindowsAzure.Plugins.Caching.NamedCaches 설정을 읽기가 더 어렵습니다. 이 설정은 JSON 구문을 사용하여 명명된 각 캐시의 속성을 설명하며, 큰따옴표가 모두 &quot;로 바뀝니다. 역할 구성 설정에 대한 참조는 역할 내 캐시 역할 구성 설정(ServiceConfiguration.cscfg)를 참조하세요.

클라이언트 구성

캐시 클라이언트는 Azure 캐시에 액세스하는 모든 애플리케이션 코드입니다. 코드에서 각 캐시 클라이언트는 DataCacheFactory 개체와 연결됩니다. 팩터리는 캐시에 액세스하는 데 사용되는 DataCache 개체를 반환합니다. 캐시 클라이언트의 실제 설정은 응용 프로그램 또는 web.config 구성 파일에서 로드될 수 있습니다.

다음 예제에서는 구성 파일에 명명된 defaultdataCacheClient 섹션을 설정하는 관련 섹션을 보여 줍니다. 이는 역할 기반 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>

이러한 클라이언트 구성 설정에 대한 참조는 역할 내 캐시 클라이언트 구성 설정(Web.config)를 참조하세요. 역할 기반 In-Role Cache의 클라이언트를 구성하는 방법을 보여 주는 연습은 방법: Azure SDK In-Role Cache 사용 방법을 참조하세요.

참고 항목

개념

Azure 캐시의 역할 내 캐시 기능
역할 내 캐시 역할 구성 설정(ServiceConfiguration.cscfg)
역할 내 캐시 클라이언트 구성 설정(Web.config)