Skip to content

Commit b71dfd6

Browse files
committed
Resolve TODO
1 parent bee970b commit b71dfd6

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/NHibernate/Impl/SessionFactoryImpl.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,8 @@ public void HandleEntityNotFound(string entityName, object id)
9595
private static readonly IIdentifierGenerator UuidGenerator = new UUIDHexGenerator();
9696

9797
[NonSerialized]
98-
// 6.0 TODO: type as CacheBase instead
99-
#pragma warning disable 618
100-
private readonly ConcurrentDictionary<string, ConcurrentDictionary<string, ICache>> allCachePerRegionThenType =
101-
new ConcurrentDictionary<string, ConcurrentDictionary<string, ICache>>();
102-
#pragma warning restore 618
98+
private readonly ConcurrentDictionary<string, ConcurrentDictionary<string, CacheBase>> allCachePerRegionThenType =
99+
new ConcurrentDictionary<string, ConcurrentDictionary<string, CacheBase>>();
103100

104101
[NonSerialized]
105102
private readonly IDictionary<string, IClassMetadata> classMetadata;
@@ -1078,7 +1075,9 @@ public IDictionary<string, ICache> GetAllSecondLevelCacheRegions()
10781075
// ToArray creates a moment in time snapshot
10791076
.ToArray()
10801077
// Caches are not unique per region, take the first one.
1081-
.ToDictionary(kv => kv.Key, kv => kv.Value.Values.First());
1078+
#pragma warning disable 618
1079+
.ToDictionary(kv => kv.Key, kv => (ICache)kv.Value.Values.First());
1080+
#pragma warning restore 618
10821081
}
10831082

10841083
// 6.0 TODO: return CacheBase instead
@@ -1102,17 +1101,15 @@ private CacheBase BuildCache(string cacheRegion, string type)
11021101
var prefix = settings.CacheRegionPrefix;
11031102
if (!string.IsNullOrEmpty(prefix))
11041103
cacheRegion = prefix + '.' + cacheRegion;
1105-
#pragma warning disable 618
1106-
var cachesPerType = allCachePerRegionThenType.GetOrAdd(cacheRegion, cr => new ConcurrentDictionary<string, ICache>());
1107-
#pragma warning restore 618
1108-
var cache = settings.CacheProvider.BuildCache(cacheRegion, properties);
1104+
var cachesPerType = allCachePerRegionThenType.GetOrAdd(cacheRegion, cr => new ConcurrentDictionary<string, CacheBase>());
1105+
var cache = settings.CacheProvider.BuildCache(cacheRegion, properties).AsCacheBase();
11091106
if (!cachesPerType.TryAdd(type, cache))
11101107
{
11111108
cache.Destroy();
11121109
throw new InvalidOperationException($"A cache has already been built for region {cacheRegion} and type {type}.");
11131110
}
11141111

1115-
return cache.AsCacheBase();
1112+
return cache;
11161113
}
11171114

11181115
/// <summary> Statistics SPI</summary>

0 commit comments

Comments
 (0)