Skip to content

Commit

Permalink
Redis ACL AUTH two argument supporting.
Browse files Browse the repository at this point in the history
Signed-off-by: Gennadii Chernykh <ragnarek45@gmail.com>
  • Loading branch information
Gennadii Chernykh committed Dec 2, 2024
1 parent 50b70a6 commit ec6feb5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Redis implements Adapter
'read_timeout' => '10',
'persistent_connections' => false,
'password' => null,
'user' => null,
];

/**
Expand Down Expand Up @@ -196,8 +197,18 @@ private function ensureOpenConnection(): void

$this->connectToServer();

if ($this->options['password'] !== null) {
$this->redis->auth($this->options['password']);
$authParams = [];

if (isset($this->options['user'])) {
$authParams[] = $this->options['user'];
}

if (isset($this->options['password'])) {
$authParams[] = $this->options['password'];
}

if (!empty($authParams)) {
$this->redis->auth($authParams);
}

if (isset($this->options['database'])) {
Expand Down

0 comments on commit ec6feb5

Please sign in to comment.