Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e89e7ae

Browse files
committedDec 8, 2022
Added redis support
1 parent 4beb179 commit e89e7ae

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed
 

‎2-WebApp-graph-user/2-2-TokenCache/Startup.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ dotnet tool install --global dotnet-sql-cache
6565
options.DefaultSlidingExpiration = TimeSpan.FromMinutes(90);
6666
});
6767

68+
// Uncomment for Redis configuration
69+
//services.AddStackExchangeRedisCache(options =>
70+
//{
71+
// options.Configuration = "localhost";//Configuration.GetConnectionString("TokenCacheRedisConnStr");
72+
// options.InstanceName = Configuration.GetConnectionString("TokenCacheRedisInstaceName");
73+
//});
74+
75+
6876
services.AddControllersWithViews(options =>
6977
{
7078
var policy = new AuthorizationPolicyBuilder()

‎2-WebApp-graph-user/2-2-TokenCache/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<ItemGroup>
2121
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" />
2222
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="3.1.8" />
23+
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="7.0.0" />
2324
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
2425
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="1.25.10" />
2526
</ItemGroup>

‎2-WebApp-graph-user/2-2-TokenCache/appsettings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"TokenCacheDbConnStr": "Data Source=(LocalDb)\\MSSQLLocalDB;Database=MY_TOKEN_CACHE_DATABASE;Trusted_Connection=True;"
2727
*/
2828
"ConnectionStrings": {
29-
"TokenCacheDbConnStr": "[Enter the Sql server connection string, e.g. Server=MY_SQL_SERVER;Database=MsalTokenCacheDatabase;Trusted_Connection=True;"
29+
"TokenCacheDbConnStr": "[Enter the Sql server connection string, e.g. Server=MY_SQL_SERVER;Database=MsalTokenCacheDatabase;Trusted_Connection=True;",
30+
"TokenCacheRedisConnStr": "[Replace with your domain like so: <your-domain>.redis.cache.windows.net:6380,password=SomeLongPassword,ssl=True,abortConnect=False or with 'localhost' if running locally]",
31+
"TokenCacheRedisInstaceName": "[Replace with your instance name]"
3032
},
3133
"Logging": {
3234
"LogLevel": {

0 commit comments

Comments
 (0)
Please sign in to comment.