Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a CacheNames property to IFusionCacheProvider #251

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
Loading