Skip to content

Commit 8c23df1

Browse files
committed
Update RedisCluster.php
1 parent 6ee6768 commit 8c23df1

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/Dashboards/Redis/Compatibility/Cluster/RedisCluster.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,11 @@ public function getInfo(?string $option = null, ?array $combine = null): array {
9090
return $option !== null ? ($info[strtolower($option)] ?? []) : $info;
9191
}
9292

93-
$section_info = [];
9493
$sections = ['SERVER', 'CLIENTS', 'MEMORY', 'PERSISTENCE', 'STATS', 'REPLICATION', 'CPU', 'CLUSTER', 'KEYSPACE'];
94+
$aggregated_data = [];
9595

96-
foreach ($sections as $section_name) {
97-
$aggregated_values = [];
98-
99-
foreach ($this->nodes as $node) {
96+
foreach ($this->nodes as $node) {
97+
foreach ($sections as $section_name) {
10098
try {
10199
$node_section_info = $this->info($node, $section_name);
102100

@@ -107,24 +105,24 @@ public function getInfo(?string $option = null, ?array $combine = null): array {
107105
foreach ($node_section_info as $key => $value) {
108106
if (is_array($value)) {
109107
foreach ($value as $sub_key => $sub_val) {
110-
$aggregated_values[$key][$sub_key][] = $sub_val;
108+
$aggregated_data[strtolower($section_name)][$key][$sub_key][] = $sub_val;
111109
}
112110
} else {
113-
$aggregated_values[$key][] = $value;
111+
$aggregated_data[strtolower($section_name)][$key][] = $value;
114112
}
115113
}
116114
} catch (RedisClusterException) {
117115
continue;
118116
}
119117
}
118+
}
120119

121-
if (empty($aggregated_values)) {
122-
continue;
123-
}
120+
$combined_info = [];
124121

122+
foreach ($aggregated_data as $section_name => $section_data) {
125123
$combined_section = [];
126124

127-
foreach ($aggregated_values as $key => $values) {
125+
foreach ($section_data as $key => $values) {
128126
if (is_array(reset($values))) {
129127
foreach ($values as $sub_key => $sub_values) {
130128
$combined_section[$key][$sub_key] = $this->combineValues((string) $sub_key, $sub_values, $combine);
@@ -133,10 +131,11 @@ public function getInfo(?string $option = null, ?array $combine = null): array {
133131
$combined_section[$key] = $this->combineValues($key, $values, $combine);
134132
}
135133
}
136-
$section_info[strtolower($section_name)] = $combined_section;
134+
135+
$combined_info[$section_name] = $combined_section;
137136
}
138137

139-
$info = $section_info;
138+
$info = $combined_info;
140139

141140
return $option !== null ? ($info[strtolower($option)] ?? []) : $info;
142141
}

0 commit comments

Comments
 (0)