@@ -278,39 +278,9 @@ You can also specify options to limit the size of the in-memory token cache:
278
278
279
279
#### Distributed caches
280
280
281
- If you use `app .AddDistributedTokenCache `, the token cache is an adapter against the .NET `IDistributedCache ` implementation . So you can choose between a distributed memory cache , a SQL Server cache , a Redis cache , or an Azure Cosmos DB cache . For details about the ` IDistributedCache ` implementations , see [ Distributed memory cache ]( / aspnet / core / performance / caching / distributed ).
281
+ If you use `app .AddDistributedTokenCache `, the token cache is an adapter against the .NET `IDistributedCache ` implementation . So you can choose between a SQL Server cache , a Redis cache , an Azure Cosmos DB cache , or any other cache implementing the [ IDistributedCache ]( https : // docs.microsoft.com/dotnet/api/microsoft.extensions.caching. distributed.idistributedcache?view=dotnet-plat-ext-6.0) interface.
282
282
283
- Here 's the code for a distributed in-memory token cache:
284
-
285
- ```CSharp
286
- // In-memory distributed token cache
287
- app .AddDistributedTokenCache (services =>
288
- {
289
- // In net462/net472, requires to reference Microsoft.Extensions.Caching.Memory
290
- services .AddDistributedMemoryCache ();
291
-
292
- // Distributed token caches have an L1/L2 mechanism.
293
- // L1 is in memory, and L2 is the distributed cache
294
- // implementation that you will choose below.
295
- // You can configure them to limit the memory of the
296
- // L1 cache, encrypt, and set eviction policies.
297
- services .Configure <MsalDistributedTokenCacheAdapterOptions >(options =>
298
- {
299
- // You can disable the L1 cache if you want
300
- options .DisableL1Cache = false ;
301
-
302
- // Or limit the memory (by default, this is 500 MB)
303
- options .sizeLimit = 1024 * 1024 * 1024 , // 1 GB
304
-
305
- // You can choose to encrypt the cache or not
306
- options .Encrypt = false ;
307
-
308
- // And you can set eviction policies for the distributed
309
- // cache
310
- options .SlidingExpiration = TimeSpan .FromHours (1 );
311
- });
312
- });
313
- ```
283
+ For testing purposes only , you may want to use `services .AddDistributedMemoryCache ()`, an in - memory implementation of `IDistributedCache `.
314
284
315
285
Here 's the code for a SQL Server cache:
316
286
@@ -320,8 +290,7 @@ Here's the code for a SQL Server cache:
320
290
{
321
291
services .AddDistributedSqlServerCache (options =>
322
292
{
323
- // In net462/net472, requires to reference Microsoft.Extensions.Caching.Memory
324
-
293
+
325
294
// Requires to reference Microsoft.Extensions.Caching.SqlServer
326
295
options .ConnectionString = @" Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=TestCache;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" ;
327
296
options .SchemaName = " dbo" ;
0 commit comments