dotnet/aspnetcore

Add ability to leverage StackExchange.Redis.CommandFlags via IDistributedCache or IDistributedRedisCache (new)

Open

#41 948 ouverte le 5 févr. 2021

Voir sur GitHub
 (27 commentaires) (16 réactions) (0 assignés)C# (10 653 forks)batch import
Needs: Designarea-middlewareenhancementfeature-cachinghelp wanted

Métriques du dépôt

Stars
 (37 933 stars)
Métriques de merge PR
 (Merge moyen 16j 9h) (258 PRs mergées en 30 j)

Description

Is your feature request related to a problem? Please describe.

I'd like to be able to specify the usage of a Replica or Slave endpoint instead of always going to the Master. This would allow me to offload traffic for read-only cache operations where the latest data is not critical resulting in improved performance.

Currently, the StackExchange.Redis.IDatabase API allows for this by use of optional StackExchange.Redis.CommandFlag enum that can be specified in API calls. However, the implementation of Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache doesn't provide these optional params to be passed thru.

Describe the solution you'd like

I would like for the implementation of Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache to provide the ability to pass a flag that allows me to specify replica usage (master, slave, replica, etc.). You would probably need to create a new interface to expose this which Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache would implement e.g. IDistributedRedisCache.

Describe alternatives you've considered

Using StackExchange.Redis.IDatabase directly instead of Microsoft's IDistributedCache wrapper. Unfortunately, it would be a lot of work to change for our applications and we do prefer the IDistributedCache wrapper in general. We also use this with Polly for caching and Polly provides a nice integration with IDistributedCache already.

Guide contributeur