Skip to content

Commit 0d3dae1

Browse files
committed
Allow for Redis info arrays which use Clients and Server keys
Signed-off-by: Tim Visser <tvisser@sacrome.com>
1 parent 4975a83 commit 0d3dae1

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/Check/Redis.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,25 @@ public function check()
5353
$stats = $client->info();
5454
$responseTime = microtime(true) - $startTime;
5555

56+
$successInformation = [
57+
"responseTime" => $responseTime,
58+
];
59+
60+
if (array_key_exists('connected_clients', $stats)) {
61+
$successInformation['connections'] = (int) $stats['connected_clients'];
62+
} elseif (array_key_exists('Clients', $stats) && array_key_exists('connected_clients', $stats['Clients'])) {
63+
$successInformation['connections'] = (int) $stats['Clients']['connected_clients'];
64+
}
65+
66+
if (array_key_exists('uptime_in_seconds', $stats)) {
67+
$successInformation['uptime'] = (int) $stats['uptime_in_seconds'];
68+
} elseif (array_key_exists('Server', $stats) && array_key_exists('uptime_in_seconds', $stats['Server'])) {
69+
$successInformation['uptime'] = (int) $stats['Server']['uptime_in_seconds'];
70+
}
71+
5672
return new Success(
5773
'',
58-
[
59-
"responseTime" => $responseTime,
60-
"connections" => (int) $stats["connected_clients"],
61-
"uptime" => (int) $stats["uptime_in_seconds"],
62-
]
74+
$successInformation
6375
);
6476
}
6577

0 commit comments

Comments
 (0)