TokenCacheExtensions.AddDistributedTokenCache 메서드

정의

분산 토큰 캐시를 추가합니다.

public static Microsoft.Identity.Client.IConfidentialClientApplication AddDistributedTokenCache(this Microsoft.Identity.Client.IConfidentialClientApplication confidentialClientApp, Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> initializeDistributedCache);
static member AddDistributedTokenCache : Microsoft.Identity.Client.IConfidentialClientApplication * Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> -> Microsoft.Identity.Client.IConfidentialClientApplication
<Extension()>
Public Function AddDistributedTokenCache (confidentialClientApp As IConfidentialClientApplication, initializeDistributedCache As Action(Of IServiceCollection)) As IConfidentialClientApplication

매개 변수

confidentialClientApp
IConfidentialClientApplication

기밀 클라이언트 애플리케이션.

initializeDistributedCache
Action<IServiceCollection>

분산 캐시를 IServiceCollection 초기화하는 작업입니다.

반품

체인을 위한 애플리케이션입니다.

예제

다음 코드는 REDIS를 기반으로 토큰 캐시를 추가하고 해당 구성을 초기화합니다.

app.AddDistributedTokenCache(services =>
{
     // Redis token cache
     // Requires to reference Microsoft.Extensions.Caching.StackExchangeRedis
     services.AddStackExchangeRedisCache(options =>
     {
         options.Configuration = "localhost";
         options.InstanceName = "Redis";
     });
});

또는 다음 코드는 PostgreSQL을 기반으로 토큰 캐시를 추가하고 해당 구성을 초기화합니다.

app.AddDistributedTokenCache(services =>
{
     // PostgreSQL token cache
     // Requires to reference Microsoft.Extensions.Caching.Postgres
     services.AddDistributedPostgresCache(options =>
     {
         options.ConnectionString = "Host=localhost;Database=mydb;Username=myuser;Password=mypassword";
         options.SchemaName = "public";
         options.TableName = "token_cache";
         options.CreateIfNotExists = true;
     });
});

설명

ASP.NET Core 이 메서드를 사용하지 마세요. 대신 ConfigureServices 메서드를 추가하기만 하면 됩니다.

적용 대상