TokenCacheExtensions.AddDistributedTokenCache Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Ajoutez un cache de jeton distribué.
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
Paramètres
- confidentialClientApp
- IConfidentialClientApplication
Application cliente confidentielle.
- initializeDistributedCache
- Action<IServiceCollection>
Action en cours IServiceCollection d’initialisation de votre cache distribué.
Retours
Application de chaînage.
Exemples
Le code suivant ajoute un cache de jetons basé sur REDIS et initialise sa configuration.
app.AddDistributedTokenCache(services =>
{
// Redis token cache
// Requires to reference Microsoft.Extensions.Caching.StackExchangeRedis
services.AddStackExchangeRedisCache(options =>
{
options.Configuration = "localhost";
options.InstanceName = "Redis";
});
});
Le code suivant ajoute également un cache de jetons basé sur PostgreSQL et initialise sa configuration.
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;
});
});
Remarques
N'utilisez pas cette méthode dans ASP.NET Core. Ajoutez simplement l’utilisation de la méthode ConfigureServices à la place.