Skip to content

Commit ace379a

Browse files
author
XieBiao
committed
fix empty password
1 parent 2b26095 commit ace379a

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

examples/reports/redis-analysis-127.0.0.1-6379-0.csv

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/AnalyzeRedis.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,22 @@ public function __construct($host, $port, $password = null)
3131
$this->port = $port;
3232
$this->redis = new \Redis();
3333
$this->redis->connect($host, $port);
34-
if ($password) {
34+
$usePassword = strlen($password) > 0;
35+
if ($usePassword) {
3536
$this->redis->auth($password);
3637
}
3738

38-
//For command: debug object <key>
39-
$this->predis = new Client([
39+
//Predis can exec the command: debug object <key>
40+
$params = [
4041
'scheme' => 'tcp',
4142
'host' => $host,
4243
'port' => $port,
43-
], [
44-
'parameters' => [
45-
'password' => $password,
46-
],
47-
]);
44+
];
45+
$options = [];
46+
if ($usePassword) {
47+
$options['parameters']['password'] = $password;
48+
}
49+
$this->predis = new Client($params, $options);
4850
}
4951

5052
public function getDatabases()

0 commit comments

Comments
 (0)