dotnetcore / dotnetcore/EasyCaching
AddEasyCaching access to IServiceProvider - Redis Services are resolved at runtime via another Service
- Dominant language
- C#
- Stars
- 2.1k
- Forks
- 336
- PR merge metrics
- No merged PRs in 30d
Description
Hi - We're trying to use the caching in an environment were the Redis endpoints are discoverable via a service registry (consul). It would be great if the `AddEasyCaching` configuration action had access to the service provider.
Do you have any recommendation to best active this with what is available today, given that the service (per `RedisEndpoints`) below is registered elsewhere, and it being not best practice to cal' `BuildServiceProvider()` directly.
The EF Core DBContext `AddDBContext` service extension for configuration as an example does provide access to the service provider,
It would be great if in future versions I could do something like the following:
```C#
services.AddEasyCaching((serviceProvider, option) =>
{
option.UseRedis(config =>
{
config.DBConfig.AllowAdmin = true;
serviceProvider.GetRequiredService().ForEach(endpoint => config.DBConfig.Endpoints.Add(new ServerEndPoint(endpoint.Host, endpoint.Port)));
}, providerName);
});
```
- Provider : Redis (version 1.1.0)
- Interceptor : Asp Net Core (version 3.1.400)
- Serializer : not use
- System : alpine
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.