@@ -13,6 +13,14 @@ internal sealed partial class MultiGroupDatabase(MultiGroupMultiplexer parent, i
1313 // for high DB numbers this might allocate even for null async-state scenarios; unavoidable for now
1414 private IDatabase GetActiveDatabase ( ) => parent . Active . GetDatabase ( database , asyncState ) ;
1515
16+ // non-throwing twin of GetActiveDatabase: returns null when the group currently has no active
17+ // member, for use by members that have an obvious trivial result when disconnected
18+ private IDatabase ? TryGetActiveDatabase ( ) => parent . TryGetActive ( ) ? . GetDatabase ( database , asyncState ) ;
19+
20+ // a completed "no endpoint" result, reused for IdentifyEndpointAsync when the group is fully down
21+ internal static readonly System . Threading . Tasks . Task < System . Net . EndPoint ? > NoEndpoint
22+ = System . Threading . Tasks . Task . FromResult < System . Net . EndPoint ? > ( null ) ;
23+
1624 // Core methods
1725 public IBatch CreateBatch ( object ? asyncState = null )
1826 => GetActiveDatabase ( ) . CreateBatch ( asyncState ) ;
@@ -27,10 +35,10 @@ public RedisValue DebugObject(RedisKey key, CommandFlags flags = CommandFlags.No
2735 => GetActiveDatabase ( ) . DebugObject ( key , flags ) ;
2836
2937 public System . Net . EndPoint ? IdentifyEndpoint ( RedisKey key = default , CommandFlags flags = CommandFlags . None )
30- => GetActiveDatabase ( ) . IdentifyEndpoint ( key , flags ) ;
38+ => TryGetActiveDatabase ( ) ? . IdentifyEndpoint ( key , flags ) ;
3139
3240 public bool IsConnected ( RedisKey key , CommandFlags flags = CommandFlags . None )
33- => GetActiveDatabase ( ) . IsConnected ( key , flags ) ;
41+ => TryGetActiveDatabase ( ) ? . IsConnected ( key , flags ) ?? false ;
3442
3543 public System . TimeSpan Ping ( CommandFlags flags = CommandFlags . None )
3644 => GetActiveDatabase ( ) . Ping ( flags ) ;
0 commit comments