3

I cannot use both StackExchange.Redis.Extensions and PersistKeysToRedis to services.AddDataProtection

I get error on PersistKeysToRedis:

cannot convert from 'StackExchange.Redis.IConnectionMultiplexer' to 'System.Func<StackExchange.Redis.IDatabase>'

To reproduce the issue:

  • Create a WebApp Core 2.2 project
  • Install-Package StackExchange.Redis.Extensions.Newtonsoft
  • Install-Package Microsoft.AspNetCore.DataProtection.Redis -Version 2.2.0-preview2-35157
  • Edit .csproj and add this fix https://stackoverflow.com/a/48758961
  • Add on ConfigureServices below code

var redis = ConnectionMultiplexer.Connect("Configuration"); services.AddDataProtection().PersistKeysToRedis(redis, "RedisKey");

Using

.PersistKeysToRedis(redis.GetDatabase(), "RedisKey");

always return an error.

So, how I can use PersistKeysToRedis keeping StackExchange.Redis.Extensions (I need it for the StackExchangeRedisCacheClient)

Sauron
  • 2,156
  • 5
  • 17
  • 20

0 Answers0