.NET Core distributed cache with password

I am using Redis Distributed Cache to temporarily cache some User-Data. I am currently testing the application locally in my development environment. Redis-Server on my local machine does not have a password, while on Production Im it uses a randomly generated password.

How to connect to Redis-Server with password?

My Startup.cs:

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

      

+3


source to share


1 answer


Microsoft.Extensions.Caching.Redis

the client is built on top StackExchange.Redis

. This means that the StackExchange Redis Connection String is used to specify the password and any other parameters, for example:



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

      

+5


source







All Articles