Add `PersistKeysToStackExchangeRedis` overload which accepts `Func<IServiceProvider, IDatabase>`
Open
api-suggestion
area-dataprotection
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
## Background and Motivation
With current overload of `PersistKeysToStackExchangeRedis`, we could not use `IConnectionMultiplexer` from service provider.
It makes us impossible to use Redis registered with `AddRedisClient` of Aspire.
## Proposed API
```C#
public static IDataProtectionBuilder PersistKeysToStackExchangeRedis(this IDataProtectionBuilder builder, Func databaseFactory, RedisKey key);
```
## Usage Examples
```C#
builder.AddRedisClient("redis");
builder.Services.AddDataProtection()
.PersistKeysToStackExchangeRedis(services => services.GetRequiredService().GetDatabase(), "DataProtection-Keys");
```
Contributor guide
Assessment
This issue has not been assessed yet.