@@ -82,47 +82,63 @@ public function getKeyType(string $key): string {
8282 * @param list<string>|null $combine
8383 *
8484 * @return array<string, array<string, mixed>>
85- *
86- * @throws RedisClusterException
8785 */
8886 public function getInfo (?string $ option = null , ?array $ combine = null ): array {
89- static $ info = [];
87+ static $ info = null ;
88+
89+ if ($ info !== null ) {
90+ return $ option !== null ? ($ info [strtolower ($ option )] ?? []) : $ info ;
91+ }
9092
91- $ options = ['SERVER ' , 'CLIENTS ' , 'MEMORY ' , 'PERSISTENCE ' , 'STATS ' , 'REPLICATION ' , 'CPU ' , 'CLUSTER ' , 'KEYSPACE ' ];
93+ $ section_info = [];
94+ $ sections = ['SERVER ' , 'CLIENTS ' , 'MEMORY ' , 'PERSISTENCE ' , 'STATS ' , 'REPLICATION ' , 'CPU ' , 'CLUSTER ' , 'KEYSPACE ' ,];
9295
93- foreach ($ options as $ option_name ) {
94- /** @var array<string, array<int, mixed>|array<string, array<int, mixed>>> $combined */
95- $ combined = [];
96+ foreach ($ sections as $ section_name ) {
97+ $ aggregated_values = [];
9698
9799 foreach ($ this ->nodes as $ node ) {
98- /** @var array<string, mixed> $node_info */
99- $ node_info = $ this ->info ($ node , $ option_name );
100+ try {
101+ $ node_section_info = $ this ->info ($ node , $ section_name );
102+
103+ if (!is_array ($ node_section_info )) {
104+ continue ;
105+ }
100106
101- foreach ($ node_info as $ key => $ value ) {
102- if (is_array ($ value )) {
103- foreach ($ value as $ sub_key => $ sub_val ) {
104- $ combined [$ key ][$ sub_key ][] = $ sub_val ;
107+ foreach ($ node_section_info as $ key => $ value ) {
108+ if (is_array ($ value )) {
109+ foreach ($ value as $ sub_key => $ sub_val ) {
110+ $ aggregated_values [$ key ][$ sub_key ][] = $ sub_val ;
111+ }
112+ } else {
113+ $ aggregated_values [$ key ][] = $ value ;
105114 }
106- } else {
107- $ combined [$ key ][] = $ value ;
108115 }
116+ } catch (RedisClusterException ) {
117+ continue ;
109118 }
110119 }
111120
112- foreach ($ combined as $ key => $ values ) {
121+ if (empty ($ aggregated_values )) {
122+ continue ;
123+ }
124+
125+ $ combined_section = [];
126+
127+ foreach ($ aggregated_values as $ key => $ values ) {
113128 if (is_array (reset ($ values ))) {
114129 foreach ($ values as $ sub_key => $ sub_values ) {
115- $ combined [$ key ][$ sub_key ] = $ this ->combineValues ($ sub_key , $ sub_values , $ combine );
130+ $ combined_section [$ key ][$ sub_key ] = $ this ->combineValues ($ sub_key , $ sub_values , $ combine );
116131 }
117132 } else {
118- $ combined [$ key ] = $ this ->combineValues ($ key , $ values , $ combine );
133+ $ combined_section [$ key ] = $ this ->combineValues ($ key , $ values , $ combine );
119134 }
120135 }
121-
122- $ info [strtolower ($ option_name )] = $ combined ;
136+ $ section_info [strtolower ($ section_name )] = $ combined_section ;
123137 }
124138
125- return $ option !== null ? ($ info [$ option ] ?? []) : $ info ;
139+ $ info = $ section_info ;
140+
141+ return $ option !== null ? ($ info [strtolower ($ option )] ?? []) : $ info ;
126142 }
127143
128144 /**
0 commit comments