首先Startup
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
// For redis
// install-package Microsoft.Extensions.Caching.Redis
services.AddDistributedRedisCache(options =>
{
options.InstanceName = Configuration.GetConnectionString("RedisName");;
options.Configuration = Configuration.GetConnectionString("RedisConnection");
});
}