Skip to content

Commit dd36cab

Browse files
authored
Merge pull request #88263 from bgavrilMS/patch-15
Update msal-net-token-cache-serialization.md
2 parents 0261b87 + 8781162 commit dd36cab

File tree

1 file changed

+3
-34
lines changed

1 file changed

+3
-34
lines changed

articles/active-directory/develop/msal-net-token-cache-serialization.md

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -278,39 +278,9 @@ You can also specify options to limit the size of the in-memory token cache:
278278

279279
#### Distributed caches
280280

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.
282282
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`.
314284

315285
Here's the code for a SQL Server cache:
316286

@@ -320,8 +290,7 @@ Here's the code for a SQL Server cache:
320290
{
321291
services.AddDistributedSqlServerCache(options =>
322292
{
323-
// In net462/net472, requires to reference Microsoft.Extensions.Caching.Memory
324-
293+
325294
// Requires to reference Microsoft.Extensions.Caching.SqlServer
326295
options.ConnectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=TestCache;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
327296
options.SchemaName = "dbo";

0 commit comments

Comments
 (0)