Add ability to leverage StackExchange.Redis.CommandFlags via IDistributedCache or IDistributedRedisCache (new)
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
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](https://github.com/StackExchange/StackExchange.Redis/blob/8612fb8a9278822c87d5476819325a7438e596ca/src/StackExchange.Redis/Enums/CommandFlags.cs#L47) 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](https://github.com/App-vNext/Polly) for caching and Polly provides a nice integration with `IDistributedCache` already.
Contributor guide
Assessment
This issue has not been assessed yet.