带密码的.NET Core Distributed Redis缓存

Yan*_*nik 4 security asp.net-mvc caching redis .net-core

我正在使用分布式Redis缓存暂时缓存一些用户数据.目前我正在我的开发环境中本地测试应用程序.我本地计算机上的Redis-Server没有密码,但在生产中我使用的是随机生成的密码.

如何使用密码连接到Redis-Server?

我的Startup.cs:

   //Add Redis
    services.AddDistributedRedisCache(options =>
    {
        options.Configuration = "127.0.0.1:6379";
        options.InstanceName = "Portal";
    });
Run Code Online (Sandbox Code Playgroud)

Ily*_*kov 10

Microsoft.Extensions.Caching.Redis客户端建立在StackExchange.Redis.这意味着StackExchange Redis连接字符串用于指定密码和任何其他选项,例如:

services.AddDistributedRedisCache(options =>
{
    options.Configuration = "localhost:6380,password=...";
    options.InstanceName = "SampleInstance";
});
Run Code Online (Sandbox Code Playgroud)