Replies: 2 comments
-
In the meantime I have checked my setup by extending the instance behind IRedisClientFactory with a simple Guid property to verify in different situations if I am really working with a single instance due to the use of the new ServiceProvider instance. |
Beta Was this translation helpful? Give feedback.
-
It's not recommended to use Why not just create a standalone private static void AddDataProtectionRedis(this IServiceCollection services, IConfiguration configuration)
{
var redisConf = configuration.GetSection("Redis").Get<RedisConfiguration>();
var redisConnStr = redisConf.ConfigurationOptions.ToString();
var conn = ConnectionMultiplexer.Connect(redisConnStr);
var redisDb = conn.GetDatabase(redisConf.Database);
services.AddDataProtection()
.SetApplicationName("MyApp")
.PersistKeysToStackExchangeRedis(() => redisDb, "MyApp-DataProtection-Keys");
} |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I am wondering how to properly configure the DataProtection when storing the data in Redis and using "PersistKeysToStackExchangeRedis" extension. Right now I use this:
IRedisDatabase is defined as a singleton in AddStackExchangeRedisExtensions:
Alternatively, I also have this way to retrieve a IDatabase instance:
So I am unsure if this is the correct approach? Especially the fact I am using "BuildServiceProvider" to create a new ServiceProvider gives me a bad feeling about this. Thanks in advance for any kind of advice.
Beta Was this translation helpful? Give feedback.
All reactions