AddStackExchangeRedisCache 和 heroku Redis 连接字符串

AddStackExchangeRedisCache and heroku Redis connection strings

我正在尝试让我的 dotnet 核心应用程序连接到具有 Stack Exchange Redis 缓存的 Heroku Redis 实例。到目前为止我有:

services.AddStackExchangeRedisCache(options =>
{
    options.Configuration = Configuration["REDIS_URL"].Replace("redis://","");
});

我得到的错误是:

StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s). UnableToConnect on

如何获取连接字符串以便 StackExchange 喜欢它?

知道了:

services.AddStackExchangeRedisCache(options =>
{
    var tokens = Configuration["REDIS_URL"].Split(':', '@');
    options.ConfigurationOptions = ConfigurationOptions.Parse(string.Format("{0}:{1},password={2}", tokens[3], tokens[4], tokens[2]));
});