dotnet / dotnet/aspnetcore

Add `PersistKeysToStackExchangeRedis` overload which accepts `Func<IServiceProvider, IDatabase>`

Open
#61,768 3 comments 6 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.