diff --git a/src/ZiggyCreatures.FusionCache/IFusionCacheProvider.cs b/src/ZiggyCreatures.FusionCache/IFusionCacheProvider.cs index ef360711..c2ae144a 100644 --- a/src/ZiggyCreatures.FusionCache/IFusionCacheProvider.cs +++ b/src/ZiggyCreatures.FusionCache/IFusionCacheProvider.cs @@ -1,4 +1,6 @@ -namespace ZiggyCreatures.Caching.Fusion; +using System.Collections.Generic; + +namespace ZiggyCreatures.Caching.Fusion; /// /// 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) @@ -18,4 +20,9 @@ public interface IFusionCacheProvider /// The name of the cache: it must match the one provided during registration. /// The FusionCache instance corresponding to the cache name specified. IFusionCache? GetCacheOrNull(string cacheName); + + /// + /// The collection of all available FusionCache names. + /// + IReadOnlyCollection CacheNames { get; } } diff --git a/src/ZiggyCreatures.FusionCache/Internals/Provider/FusionCacheProvider.cs b/src/ZiggyCreatures.FusionCache/Internals/Provider/FusionCacheProvider.cs index ca07492d..fb02c042 100644 --- a/src/ZiggyCreatures.FusionCache/Internals/Provider/FusionCacheProvider.cs +++ b/src/ZiggyCreatures.FusionCache/Internals/Provider/FusionCacheProvider.cs @@ -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 CacheNames => _lazyNamedCaches.Select(e => e.CacheName).ToList(); }