Skip to content

Commit b758c6f

Browse files
authored
Update msal-net-token-cache-serialization.md
1 parent f25d603 commit b758c6f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,12 @@ Instead of `app.AddInMemoryTokenCache();` you can use different caching serializ
233233
<a id='no-token-cache-serialization' />
234234
#### Token Cache without serialization
235235

236-
You can specify that you don't want to have any token cache serialization and rely on MSAL.NET internal cache, if you:
236+
You can specify that you don't want to have any token cache serialization and rely on MSAL.NET internal cache. :
237237
- Use `.WithCacheOptions(CacheOptions.EnableSharedCacheOptions)` when you build the application.
238238
- Don't add any serializer.
239239

240+
241+
240242
```CSharp
241243
// Create the confidential client application
242244
app= ConfidentialClientApplicationBuilder.Create(clientId)
@@ -247,6 +249,8 @@ You can specify that you don't want to have any token cache serialization and re
247249
.WithAuthority(authority)
248250
.Build();
249251
```
252+
\
253+
`WithCacheOptions(CacheOptions.EnableSharedCacheOptions)` makes the internal MSAL token cache to be shared between different MSAL client application instances. This is faster than using any token cache serialization, however, the internal in-memory token cache does not have eviction policies. Existing tokens will be refreshed in-place, but fetching tokens for different resources, users, tenants, etc. will make the cache grow accordingly. If you use this approach and have a lot of users/tenants, make to sure to monitor the memory footprint and if it becomes an issue, consider enabling token cache serialization which can reduce the internal cache size. Additionally, be aware that these two features, shared cache and cache serialization, are not currently supported toghter.
250254

251255
#### In memory token cache
252256

0 commit comments

Comments
 (0)