From 908ed6b73a88d408c5ca8f98c93610c0dbdfbb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?= <12201973+fredericdelaporte@users.noreply.github.com> Date: Sun, 17 Sep 2023 17:47:35 +0200 Subject: [PATCH] Throw a more explanatory error with the advanced strategies --- .../DefaultCacheRegionStrategyFactory.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/StackExchangeRedis/NHibernate.Caches.StackExchangeRedis/DefaultCacheRegionStrategyFactory.cs b/StackExchangeRedis/NHibernate.Caches.StackExchangeRedis/DefaultCacheRegionStrategyFactory.cs index b1a28666..0433f575 100644 --- a/StackExchangeRedis/NHibernate.Caches.StackExchangeRedis/DefaultCacheRegionStrategyFactory.cs +++ b/StackExchangeRedis/NHibernate.Caches.StackExchangeRedis/DefaultCacheRegionStrategyFactory.cs @@ -19,6 +19,18 @@ public virtual AbstractRegionStrategy Create(IConnectionMultiplexer connectionMu { return new FastRegionStrategy(connectionMultiplexer, configuration, properties); } + + if (configuration.RegionStrategy == typeof(FastTwoLayerCacheRegionStrategy) || + configuration.RegionStrategy == typeof(TwoLayerCacheRegionStrategy) || + configuration.RegionStrategy == typeof(DistributedLocalCacheRegionStrategy)) + { + throw new CacheException( + $"{configuration.RegionStrategy} is not supported by {GetType()}, register " + + $"a custom {typeof(ICacheRegionStrategyFactory)} or use a supported one. " + + $"{configuration.RegionStrategy} requires an application provided implementation " + + $"of {nameof(RegionMemoryCacheBase)} and cannot be directly supported by the " + + $"{nameof(DefaultCacheRegionStrategyFactory)}."); + } throw new CacheException( $"{configuration.RegionStrategy} is not supported by {GetType()}, register " +