Add ability to leverage StackExchange.Redis.CommandFlags via IDistributedCache or IDistributedRedisCache (new)
#41.948 aperta il 5 feb 2021
Metriche repository
- Star
- (37.933 star)
- Metriche merge PR
- (Merge medio 16g 9h) (258 PR mergiate in 30 g)
Descrizione
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.