File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public class CachingService : IAppCache
1313 {
1414 private readonly Lazy < ICacheProvider > cacheProvider ;
1515
16- private readonly int [ ] keyLocks = new int [ 32 ] ;
16+ private readonly int [ ] keyLocks ;
1717
1818 public CachingService ( ) : this ( DefaultCacheProvider )
1919 {
@@ -22,12 +22,17 @@ public CachingService() : this(DefaultCacheProvider)
2222 public CachingService ( Lazy < ICacheProvider > cacheProvider )
2323 {
2424 this . cacheProvider = cacheProvider ?? throw new ArgumentNullException ( nameof ( cacheProvider ) ) ;
25+ var lockCount = Math . Max ( Environment . ProcessorCount * 8 , 32 ) ;
26+ keyLocks = new int [ lockCount ] ;
2527 }
2628
2729 public CachingService ( Func < ICacheProvider > cacheProviderFactory )
2830 {
2931 if ( cacheProviderFactory == null ) throw new ArgumentNullException ( nameof ( cacheProviderFactory ) ) ;
3032 cacheProvider = new Lazy < ICacheProvider > ( cacheProviderFactory ) ;
33+ var lockCount = Math . Max ( Environment . ProcessorCount * 8 , 32 ) ;
34+ keyLocks = new int [ lockCount ] ;
35+
3136 }
3237
3338 public CachingService ( ICacheProvider cache ) : this ( ( ) => cache )
You can’t perform that action at this time.
0 commit comments