Skip to content

Commit c481a38

Browse files
Fall back to using old command when GetServer isn't supported. (#41649)
1 parent 9a81d79 commit c481a38

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Caching/StackExchangeRedis/src/RedisCache.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,23 @@ private void ValidateServerFeatures()
292292
{
293293
_ = _connection ?? throw new InvalidOperationException($"{nameof(_connection)} cannot be null.");
294294

295-
foreach (var endPoint in _connection.GetEndPoints())
295+
try
296296
{
297-
if (_connection.GetServer(endPoint).Version < ServerVersionWithExtendedSetCommand)
297+
foreach (var endPoint in _connection.GetEndPoints())
298298
{
299-
_setScript = SetScriptPreExtendedSetCommand;
300-
return;
299+
if (_connection.GetServer(endPoint).Version < ServerVersionWithExtendedSetCommand)
300+
{
301+
_setScript = SetScriptPreExtendedSetCommand;
302+
return;
303+
}
301304
}
302305
}
306+
catch (NotSupportedException)
307+
{
308+
// The GetServer call may not be supported with some configurations, in which
309+
// case let's also fall back to using the older command.
310+
_setScript = SetScriptPreExtendedSetCommand;
311+
}
303312
}
304313

305314
private void TryRegisterProfiler()

0 commit comments

Comments
 (0)