diff --git a/Directory.Build.props b/Directory.Build.props index 66886ae..3c5f002 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,6 +23,7 @@ 1.0.0 + 2.1.1 2.3.1 4.19.4 15.6.0 diff --git a/src/Orleans.Redis.Common/CachedConnectionMultiplexerFactory.cs b/src/Orleans.Redis.Common/CachedConnectionMultiplexerFactory.cs index a1b9e35..ec4b154 100644 --- a/src/Orleans.Redis.Common/CachedConnectionMultiplexerFactory.cs +++ b/src/Orleans.Redis.Common/CachedConnectionMultiplexerFactory.cs @@ -14,7 +14,7 @@ public class CachedConnectionMultiplexerFactory : IConnectionMultiplexerFactory { public static IConnectionMultiplexerFactory Default = new CachedConnectionMultiplexerFactory(); - private readonly SemaphoreSlim _lock = new SemaphoreSlim(1); + private readonly SemaphoreSlim _lock = new SemaphoreSlim(1, 1); private readonly Dictionary _connectionMultiplexers = new Dictionary(); internal Dictionary TestHook_ConnectionMultiplexers => _connectionMultiplexers; @@ -24,15 +24,20 @@ public async Task CreateAsync(string configuration) { if (!_connectionMultiplexers.TryGetValue(configuration, out var connectionMultiplexer)) { - await _lock.WaitAsync(); + try + { + await _lock.WaitAsync(); - if (!_connectionMultiplexers.TryGetValue(configuration, out connectionMultiplexer)) + if (!_connectionMultiplexers.TryGetValue(configuration, out connectionMultiplexer)) + { + connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync(configuration); + _connectionMultiplexers.Add(configuration, connectionMultiplexer); + } + } + finally { - connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync(configuration); - _connectionMultiplexers.Add(configuration, connectionMultiplexer); + _lock.Release(); } - - _lock.Release(); } return connectionMultiplexer; diff --git a/src/Orleans.Streaming.Redis/Providers/Streams/RedisQueueAdapter.cs b/src/Orleans.Streaming.Redis/Providers/Streams/RedisQueueAdapter.cs index 331e5ef..3ea159f 100644 --- a/src/Orleans.Streaming.Redis/Providers/Streams/RedisQueueAdapter.cs +++ b/src/Orleans.Streaming.Redis/Providers/Streams/RedisQueueAdapter.cs @@ -50,7 +50,7 @@ public RedisQueueAdapter( Name = providerName; _streamQueueMapper = streamQueueMapper; _dataAdapter = dataAdapter; - _logger = logger != null ? logger.ForContext() : SilentLogger.Logger; + _logger = (logger ?? SilentLogger.Logger).ForContext(); } public IQueueAdapterReceiver CreateReceiver(QueueId queueId) diff --git a/src/Orleans.Streaming.Redis/Providers/Streams/RedisStreamBuilder.cs b/src/Orleans.Streaming.Redis/Providers/Streams/RedisStreamBuilder.cs index 1ac185e..f17efdf 100644 --- a/src/Orleans.Streaming.Redis/Providers/Streams/RedisStreamBuilder.cs +++ b/src/Orleans.Streaming.Redis/Providers/Streams/RedisStreamBuilder.cs @@ -18,7 +18,7 @@ public SiloRedisStreamConfigurator(string name, ISiloHostBuilder builder) .ConfigureApplicationParts(parts => parts.AddFrameworkPart(typeof(RedisQueueAdapterFactory).Assembly)) .ConfigureServices(services => { - services.ConfigureNamedOptionForLogging(name); + services.ConfigureNamedOptionForLogging(name); services.TryAddSingleton(CachedConnectionMultiplexerFactory.Default); services.TryAddSingleton(); services.AddSingleton(); diff --git a/test/CoreTests/CoreTests.csproj b/test/CoreTests/CoreTests.csproj index 2bdb36b..d08bcac 100644 --- a/test/CoreTests/CoreTests.csproj +++ b/test/CoreTests/CoreTests.csproj @@ -1,6 +1,6 @@ - netcoreapp2.0 + netcoreapp2.1 false 2.0.3 Debug;Release;Test diff --git a/test/Shared/Shared.csproj b/test/Shared/Shared.csproj index 8f25499..11b2620 100644 --- a/test/Shared/Shared.csproj +++ b/test/Shared/Shared.csproj @@ -5,7 +5,7 @@ - + diff --git a/test/StorageTests.GrainInterfaces/StorageTests.GrainInterfaces.csproj b/test/StorageTests.GrainInterfaces/StorageTests.GrainInterfaces.csproj index a3458b2..619c39c 100644 --- a/test/StorageTests.GrainInterfaces/StorageTests.GrainInterfaces.csproj +++ b/test/StorageTests.GrainInterfaces/StorageTests.GrainInterfaces.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + netcoreapp2.1 false 2.0.3 Debug;Release;Test diff --git a/test/StorageTests/StorageTests.csproj b/test/StorageTests/StorageTests.csproj index 130ad3e..06b8489 100644 --- a/test/StorageTests/StorageTests.csproj +++ b/test/StorageTests/StorageTests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + netcoreapp2.1 false 2.0.3 Debug;Release;Test @@ -17,8 +17,8 @@ - - + + all runtime; build; native; contentfiles; analyzers