|
|
@ -94,13 +94,21 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Model |
|
|
|
|
|
|
|
private async Task ConnectToRedisAsync() |
|
|
|
{ |
|
|
|
//TODO: Need to make this more robust. Also want to understand why the static connection method cannot accept dns names.
|
|
|
|
var ips = await Dns.GetHostAddressesAsync(_settings.ConnectionString); |
|
|
|
_logger.LogInformation($"Connecting to database {_settings.ConnectionString} at IP {ips.First().ToString()}"); |
|
|
|
_redis = await ConnectionMultiplexer.ConnectAsync(ips.First().ToString()); |
|
|
|
// TODO: Need to make this more robust. ConnectionMultiplexer.ConnectAsync doesn't like domain names or IPv6 addresses.
|
|
|
|
if (IPAddress.TryParse(_settings.ConnectionString, out var ip)) |
|
|
|
{ |
|
|
|
_redis = await ConnectionMultiplexer.ConnectAsync(ip.ToString()); |
|
|
|
_logger.LogInformation($"Connecting to database at {_settings.ConnectionString}"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// workaround for https://github.com/StackExchange/StackExchange.Redis/issues/410
|
|
|
|
var ips = await Dns.GetHostAddressesAsync(_settings.ConnectionString); |
|
|
|
_logger.LogInformation($"Connecting to database {_settings.ConnectionString} at IP {ips.First().ToString()}"); |
|
|
|
_redis = await ConnectionMultiplexer.ConnectAsync(ips.First().ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|