dotnet/aspnetcore

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

Open

#41.948 geöffnet am 5. Feb. 2021

Auf GitHub ansehen
 (27 Kommentare) (16 Reaktionen) (0 zugewiesene Personen)C# (10.653 Forks)batch import
Needs: Designarea-middlewareenhancementfeature-cachinghelp wanted

Repository-Metriken

Stars
 (37.933 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 16T 9h) (258 gemergte PRs in 30 T)

Beschreibung

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.

Contributor Guide