@@ -368,7 +368,7 @@ public SessionFactoryImpl(Configuration cfg, IMapping mapping, Settings settings
368
368
if ( settings . IsQueryCacheEnabled )
369
369
{
370
370
var updateTimestampsCacheName = typeof ( UpdateTimestampsCache ) . Name ;
371
- updateTimestampsCache = new UpdateTimestampsCache ( BuildCache ( updateTimestampsCacheName ) ) ;
371
+ updateTimestampsCache = new UpdateTimestampsCache ( GetCache ( updateTimestampsCacheName ) ) ;
372
372
var queryCacheName = typeof ( StandardQueryCache ) . FullName ;
373
373
queryCache = BuildQueryCache ( queryCacheName ) ;
374
374
queryCaches = new ConcurrentDictionary < string , Lazy < IQueryCache > > ( ) ;
@@ -415,7 +415,7 @@ private IQueryCache BuildQueryCache(string queryCacheName)
415
415
settings . QueryCacheFactory . GetQueryCache (
416
416
updateTimestampsCache ,
417
417
properties ,
418
- BuildCache ( queryCacheName ) )
418
+ GetCache ( queryCacheName ) )
419
419
// 6.0 TODO: remove the coalesce once IQueryCacheFactory todos are done
420
420
#pragma warning disable 618
421
421
?? settings . QueryCacheFactory . GetQueryCache (
@@ -432,14 +432,14 @@ private ICacheConcurrencyStrategy GetCacheConcurrencyStrategy(
432
432
bool isMutable ,
433
433
Dictionary < Tuple < string , string > , ICacheConcurrencyStrategy > caches )
434
434
{
435
- var cacheKey = new Tuple < string , string > ( cacheRegion , strategy ) ;
436
435
if ( strategy == null || ! settings . IsSecondLevelCacheEnabled )
437
436
return null ;
438
437
438
+ var cacheKey = new Tuple < string , string > ( cacheRegion , strategy ) ;
439
439
if ( caches . TryGetValue ( cacheKey , out var cache ) )
440
440
return cache ;
441
-
442
- cache = CacheFactory . CreateCache ( strategy , BuildCache ( cacheRegion ) ) ;
441
+
442
+ cache = CacheFactory . CreateCache ( strategy , GetCache ( cacheRegion ) ) ;
443
443
caches . Add ( cacheKey , cache ) ;
444
444
if ( isMutable && strategy == CacheFactory . ReadOnly )
445
445
log . Warn ( "read-only cache configured for mutable: {0}" , name ) ;
@@ -878,8 +878,11 @@ public void Close()
878
878
{
879
879
cache . Value . Destroy ( ) ;
880
880
}
881
+ }
881
882
882
- updateTimestampsCache . Destroy ( ) ;
883
+ foreach ( var cache in _allCacheRegions . Values )
884
+ {
885
+ cache . Destroy ( ) ;
883
886
}
884
887
885
888
settings . CacheProvider . Stop ( ) ;
@@ -1083,7 +1086,7 @@ public ICache GetSecondLevelCacheRegion(string regionName)
1083
1086
return result ;
1084
1087
}
1085
1088
1086
- private CacheBase BuildCache ( string cacheRegion )
1089
+ private CacheBase GetCache ( string cacheRegion )
1087
1090
{
1088
1091
// If run concurrently for the same region and type, this may built many caches for the same region and type.
1089
1092
// Currently only GetQueryCache may be run concurrently, and its implementation prevents
0 commit comments