a question about understanding which redis database is used and how it can be configured.
I have a default ASP.NET web application and a local redis server configured by default (containing 15 databases)

In the package management console, I installed:
Install-Package Microsoft.Extensions.Caching.Redis
Redis is configured in Startup.cs as follows:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddDistributedRedisCache(option =>
{
option.Configuration = "127.0.0.1";
option.InstanceName = "master";
});
}
The code for reading and writing values ββto the cache is taken from the documents:
var cacheKey = "TheTime";
var existingTime = _distributedCache.GetString(cacheKey);
if (!string.IsNullOrEmpty(existingTime))
{
return "Fetched from cache : " + existingTime;
}
else
{
existingTime = DateTime.UtcNow.ToString();
_distributedCache.SetString(cacheKey, existingTime);
return "Added to cache : " + existingTime;
}
But this code only uses the db0 database by default, regardless of what I'm setting up.
eg. using this configuration:
services.AddDistributedRedisCache(option =>
{
option.Configuration = "127.0.0.1";
option.InstanceName = "db6";
});
leads to:

What do I need to configure for use, for example? DB6?
Do I need to use Stackexchange.Redis for this?
source
share