Upgrade ExtendedCache to support non-Redis distributed cache (#6682)
* Upgrade ExtendedCache to support non-Redis distributed cache
* Update CACHING.md to use UseSharedDistributedCache setting
Updated documentation to reflect the setting rename from UseSharedRedisCache
to UseSharedDistributedCache in the ExtendedCache configuration examples.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Matt Bishop <withinfocus@users.noreply.github.com>
@ -18,9 +18,12 @@ public static class ExtendedCacheServiceCollectionExtensions
@@ -18,9 +18,12 @@ public static class ExtendedCacheServiceCollectionExtensions
/// Adds a new, named Fusion Cache <see href="https://github.com/ZiggyCreatures/FusionCache"/> to the service
/// collection. If an existing cache of the same name is found, it will do nothing.<br/>
/// <br/>
/// <b>Note</b>: When re-using the existing Redis cache, it is expected to call this method <b>after</b> calling
/// <code>services.AddDistributedCache(globalSettings)</code><br />This ensures that DI correctly finds,
/// configures, and re-uses all the shared Redis architecture.
/// <b>Note</b>: When re-using an existing distributed cache, it is expected to call this method <b>after</b> calling
/// <code>services.AddDistributedCache(globalSettings)</code><br />This ensures that DI correctly finds
/// and re-uses the shared distributed cache infrastructure.<br />
/// <br />
/// <b>Backplane</b>: Cross-instance cache invalidation is only available when using Redis.
/// Non-Redis distributed caches operate with eventual consistency across multiple instances.
/// </summary>
publicstaticIServiceCollectionAddExtendedCache(
thisIServiceCollectionservices,
@ -72,12 +75,21 @@ public static class ExtendedCacheServiceCollectionExtensions
@@ -72,12 +75,21 @@ public static class ExtendedCacheServiceCollectionExtensions
if(!settings.EnableDistributedCache)
returnservices;
if(settings.UseSharedRedisCache)
if(settings.UseSharedDistributedCache)
{
// Using Shared Redis, TryAdd and reuse all pieces (multiplexer, distributed cache and backplane)
@ -92,13 +104,13 @@ public static class ExtendedCacheServiceCollectionExtensions
@@ -92,13 +104,13 @@ public static class ExtendedCacheServiceCollectionExtensions
@ -107,10 +119,21 @@ public static class ExtendedCacheServiceCollectionExtensions
@@ -107,10 +119,21 @@ public static class ExtendedCacheServiceCollectionExtensions
returnservices;
}
// Using keyed Redis / Distributed Cache. Create all pieces as keyed services.
// Using keyed Distributed Cache. Create/Reuse all pieces as keyed services.
@ -7,6 +7,7 @@ using NSubstitute;
@@ -7,6 +7,7 @@ using NSubstitute;
usingStackExchange.Redis;
usingXunit;
usingZiggyCreatures.Caching.Fusion;
usingZiggyCreatures.Caching.Fusion.Backplane;
namespaceBit.Core.Test.Utilities;
@ -167,7 +168,7 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@@ -167,7 +168,7 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@ -187,7 +188,7 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@@ -187,7 +188,7 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@ -242,7 +243,7 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@@ -242,7 +243,7 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@ -261,13 +262,13 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@@ -261,13 +262,13 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@ -294,7 +295,7 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@@ -294,7 +295,7 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@ -306,6 +307,180 @@ public class ExtendedCacheServiceCollectionExtensionsTests
@@ -306,6 +307,180 @@ public class ExtendedCacheServiceCollectionExtensionsTests