Skip to content

Commit 24528fb

Browse files
Throw a more explanatory error with the advanced strategies
1 parent 196296f commit 24528fb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

StackExchangeRedis/NHibernate.Caches.StackExchangeRedis/DefaultCacheRegionStrategyFactory.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using NHibernate.Cache;
34
using StackExchange.Redis;
45

@@ -19,6 +20,18 @@ public virtual AbstractRegionStrategy Create(IConnectionMultiplexer connectionMu
1920
{
2021
return new FastRegionStrategy(connectionMultiplexer, configuration, properties);
2122
}
23+
24+
if (configuration.RegionStrategy == typeof(FastTwoLayerCacheRegionStrategy) ||
25+
configuration.RegionStrategy == typeof(TwoLayerCacheRegionStrategy) ||
26+
configuration.RegionStrategy == typeof(DistributedLocalCacheRegionStrategy))
27+
{
28+
throw new CacheException(
29+
$"{configuration.RegionStrategy} is not supported by {GetType()}, register " +
30+
$"a custom {typeof(ICacheRegionStrategyFactory)} or use a supported one. " +
31+
$"{configuration.RegionStrategy} requires an application provided implementation " +
32+
$"of {nameof(RegionMemoryCacheBase)} and cannot be directly supported by the " +
33+
$"{nameof(DefaultCacheRegionStrategyFactory)}.");
34+
}
2235

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

0 commit comments

Comments
 (0)