Skip to content

Commit 6c0ed26

Browse files
committed
Update RedisTrait.php
1 parent f0120a8 commit 6c0ed26

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/Dashboards/Redis/RedisTrait.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ private function panels(): string {
3030
}
3131

3232
try {
33-
$info = $this->redis->getInfo();
33+
$info = $this->redis->getInfo(null, [
34+
'redis_version',
35+
'used_memory',
36+
'maxmemory',
37+
'keyspace_hits',
38+
'keyspace_misses',
39+
'total_connections_received',
40+
'total_commands_processed',
41+
]);
3442

3543
$panels = [
3644
$this->mainPanel($info, $title ?? null),
@@ -77,7 +85,7 @@ private function mainPanel(array $info, ?string $title): array {
7785
'Cluster' => ($cluster_info['cluster_enabled'] ?? 0) ? 'Enabled' : 'Disabled',
7886
'Uptime' => Format::seconds((int) ($server_info['uptime_in_seconds'] ?? 0)),
7987
$role,
80-
'Keys' => Format::number($this->getKeysCountFromInfo($info)).($this->is_cluster ? '' : ' (all databases)'),
88+
'Keys' => Format::number($this->getKeysCountFromInfo($info)).' (all databases)',
8189
['Hits / Misses', Format::number($hits).' / '.Format::number($misses).' ('.$hit_rate.'%)', $hit_rate, 'higher'],
8290
];
8391

@@ -94,10 +102,11 @@ private function mainPanel(array $info, ?string $title): array {
94102
* @throws Exception
95103
*/
96104
private function getKeysCountFromInfo(array $info): int {
97-
$keyspace_info = $info['keyspace'] ?? [];
98105
$count_of_all_keys = 0;
99106

100-
if (!$this->is_cluster && $keyspace_info !== []) {
107+
if (!$this->is_cluster) {
108+
$keyspace_info = $info['keyspace'] ?? [];
109+
101110
foreach ($keyspace_info as $entry) {
102111
if (is_string($entry) && str_contains($entry, 'keys=')) {
103112
parse_str(str_replace(',', '&', $entry), $parsed);

0 commit comments

Comments
 (0)