Skip to content

Commit

Permalink
Xml comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jodydonetti committed Dec 9, 2024
1 parent c4442ee commit a429ea8
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class FusionHybridCacheServiceCollectionExtensions
{
/// <summary>
/// Register this FusionCache instance also as a <see cref="HybridCache"/> service, so that it can be used even when you need to depend on Microsoft's own hybrid cache abstraction.
/// </summary>
/// <param name="builder">The <see cref="IFusionCacheBuilder" /> to act upon.</param>
/// <returns></returns>
public static IFusionCacheBuilder AsHybridCache(this IFusionCacheBuilder builder)
{
builder.Services.AddSingleton<HybridCache>(sp =>
Expand All @@ -19,6 +24,16 @@ public static IFusionCacheBuilder AsHybridCache(this IFusionCacheBuilder builder
return builder;
}

/// <summary>
/// Register this FusionCache instance also as a keyed <see cref="HybridCache"/> service, so that it can be used even when you need to depend on Microsoft's own hybrid cache abstraction, and even with the [FromKeyedServices] attribute usage.
/// <br/><br/>
/// <strong>DOCS:</strong> <see href="https://github.com/ZiggyCreatures/FusionCache/blob/main/docs/DependencyInjection.md"/>
/// <br/><br/>
/// <strong>DOCS:</strong> <see href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-8.0#keyed-services"/>
/// </summary>
/// <param name="builder">The <see cref="IFusionCacheBuilder" /> to act upon.</param>
/// <param name="serviceKey">The keyed service key to use.</param>
/// <returns></returns>
public static IFusionCacheBuilder AsKeyedHybridCache(this IFusionCacheBuilder builder, object? serviceKey)
{
builder.Services.AddKeyedSingleton<HybridCache>(serviceKey, (sp, _) =>
Expand All @@ -29,6 +44,15 @@ public static IFusionCacheBuilder AsKeyedHybridCache(this IFusionCacheBuilder bu
return builder;
}

/// <summary>
/// Register this FusionCache instance also as a keyed <see cref="HybridCache"/> service (with the CacheName as the serviceKey), so that it can be used even when you need to depend on Microsoft's own hybrid cache abstraction, and even with the [FromKeyedServices] attribute usage.
/// <br/><br/>
/// <strong>DOCS:</strong> <see href="https://github.com/ZiggyCreatures/FusionCache/blob/main/docs/DependencyInjection.md"/>
/// <br/><br/>
/// <strong>DOCS:</strong> <see href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-8.0#keyed-services"/>
/// </summary>
/// <param name="builder">The <see cref="IFusionCacheBuilder" /> to act upon.</param>
/// <returns></returns>
public static IFusionCacheBuilder AsKeyedHybridCacheByCacheName(this IFusionCacheBuilder builder)
{
return builder.AsKeyedHybridCache(builder.CacheName);
Expand Down

0 comments on commit a429ea8

Please sign in to comment.