December 2019
Intermediate to advanced
494 pages
11h 41m
English
Open up Visual Studio 2017 and create a new console application. Install the Microsoft.Extensions.Caching.Redis package using NuGet. Yes, Microsoft has its own package for working with Redis and it includes MVC Core extensions! However, we're using a console application and not an MVC application:
using Microsoft.Extensions.Caching.Distributed;// [...]namespace RedisConnection{ internal class Program { private static void Main(string[] args) { var redisOptions = new RedisCacheOptions { Configuration = "[your connection string]", InstanceName = "[your DNS name]" }; var options = Options.Create(redisOptions); // This would be injected in MVC Core. IDistributedCache cache = new RedisCache(options); cache.SetString("name", ...