Implementing Redis in ASP.NET Core
So, let's use the Redis we just installed on our machines by integrating it with our existing ASP.NET Core 5 solution. Here are the steps:
- Go to the
Travel.Application
project and install these NuGet packages. The following NuGet package is a distributed cache implementation of theMicrosoft.Extensions.Caching.StackExchangeRedis
namespace using Redis:Microsoft.Extensions.Caching.StackExchangeRedis
The following NuGet package helps us retrieve the configuration in
appsettings.json
:Microsoft.Extensions.Configuration
The following NuGet package is a JSON framework for .NET:
Newtonsoft.Json
- Next, we update the
DependencyInjection.cs
file of theTravel.Application
project with the following code:namespace Travel.Application { public static class DependencyInjection { public static IServiceCollection &...