From 068e629edecc166e7305c5ead1e5113db22bb42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?= <12201973+fredericDelaporte@users.noreply.github.com> Date: Fri, 10 May 2024 03:32:53 +0200 Subject: [PATCH] Throw a more explanatory error with the advanced strategies (#125) --- .../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 " +