Skip to content

Commit 068e629

Browse files
Throw a more explanatory error with the advanced strategies (#125)
1 parent 71e9fe8 commit 068e629

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

StackExchangeRedis/NHibernate.Caches.StackExchangeRedis/DefaultCacheRegionStrategyFactory.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ public virtual AbstractRegionStrategy Create(IConnectionMultiplexer connectionMu
1919
{
2020
return new FastRegionStrategy(connectionMultiplexer, configuration, properties);
2121
}
22+
23+
if (configuration.RegionStrategy == typeof(FastTwoLayerCacheRegionStrategy) ||
24+
configuration.RegionStrategy == typeof(TwoLayerCacheRegionStrategy) ||
25+
configuration.RegionStrategy == typeof(DistributedLocalCacheRegionStrategy))
26+
{
27+
throw new CacheException(
28+
$"{configuration.RegionStrategy} is not supported by {GetType()}, register " +
29+
$"a custom {typeof(ICacheRegionStrategyFactory)} or use a supported one. " +
30+
$"{configuration.RegionStrategy} requires an application provided implementation " +
31+
$"of {nameof(RegionMemoryCacheBase)} and cannot be directly supported by the " +
32+
$"{nameof(DefaultCacheRegionStrategyFactory)}.");
33+
}
2234

2335
throw new CacheException(
2436
$"{configuration.RegionStrategy} is not supported by {GetType()}, register " +

0 commit comments

Comments
 (0)