Skip to content

Commit

Permalink
Add a CacheNames property to IFusionCacheProvider
Browse files Browse the repository at this point in the history
Note: this is a breaking change since it adds an interface member.
  • Loading branch information
0xced authored and jodydonetti committed Jun 23, 2024
1 parent 9d7a585 commit e2b8e70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ZiggyCreatures.FusionCache/IFusionCacheProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace ZiggyCreatures.Caching.Fusion;
using System.Collections.Generic;

namespace ZiggyCreatures.Caching.Fusion;

/// <summary>
/// The provider to work with multiple named FusionCache instances, kinda like Microsoft's HTTP named clients (see https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-requests#named-clients)
Expand All @@ -18,4 +20,9 @@ public interface IFusionCacheProvider
/// <param name="cacheName">The name of the cache: it must match the one provided during registration.</param>
/// <returns>The FusionCache instance corresponding to the cache name specified.</returns>
IFusionCache? GetCacheOrNull(string cacheName);

/// <summary>
/// The collection of all available FusionCache names.
/// </summary>
IReadOnlyCollection<string> CacheNames { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ public IFusionCache GetCache(string cacheName)
: $"No cache has been registered with name ({cacheName}): make sure you registered it with the AddFusionCache(\"{cacheName}\") method."
);
}

public IReadOnlyCollection<string> CacheNames => _lazyNamedCaches.Select(e => e.CacheName).ToList();
}

0 comments on commit e2b8e70

Please sign in to comment.