Skip to content

[FEATURE] Expose configured services, e.g. for distributed cache and backplane #443

@angularsen

Description

@angularsen

Problem

When using services.AddFusionCache().TryWithAutoSetup() it is not always clear which registered services are actually used by any given FusionCache instance.

For instance, in our tests we re-configure services.AddFusionCache() in order to disable Redis as distributed cache for our tests. This tripped me up when trying to write tests to create a repro for our issue, so I wanted to add some logging in .WithPostSetup(ServiceProvider, FusionCache) to log exactly what services are used, not just true/false on HasBackplane and HasDistributedCache.

Right now I just need the service type for each, but I imagine it could be useful to access the actual service object too, in order to call methods to query its config or state.

Solution

Public property accessors for the underlying service used by FusionCache, particularly for distributed cache and backplane. There are a number of services configured in FusionCacheBuilder.Build that are not publicly available in FusionCache when built.

Alternatives

Manual inspection during debugging, reflection to get internal properties, or calling sp.GetService<IDistributedCache>() and sp.GetService<IFusionCacheBackplane>() hoping the registered services are actually used and not overridden with WithBackplane() and WithDistributedCache().

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions