Redis Cache : Allow Redis Connection Disposal to be controlled externally
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
I have a service where I manage the `ServiceProvider`, then I have a method that will create the `ServiceScope` (and later dispose) based on messages I'm receiving since the context of each scope can change base on configurations in the message. My `RedisCacheOption` is setup with `ConnectionMultiplexerFactory` pointing to a class where I handle the Redis connection myself, outside of DI.
So far I diagnosed that when the `ServiceProvider` is disposed and needs to be rebuilt (part of a recovery logic), it will also dispose the `IDistributedCache` -> `RedisCache` which is referencing my connection that I manage externally and it is disposing it causing issues in other places.
### Describe the solution you'd like
I would like to be able to tell in RedisCacheOptions that I'm managing the Redis Connection
### Additional context
_No response_
Contributor guide
Research direction
Start by tracing RedisCacheOptions.ConnectionMultiplexerFactory and the RedisCache disposal path in the Redis cache implementation. Define how an option indicating externally managed connections should affect disposal, then verify the recovery scenario where the ServiceProvider is rebuilt without disposing the externally managed Redis connection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, redis
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100