-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from robin-brabants/feature/redis-cluster-use…
…rname Add support for specific `username` setting in `RedisCluster`
- Loading branch information
Showing
10 changed files
with
218 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
/.phpunit.result.cache | ||
/.phpunit.cache | ||
/.psalm-cache | ||
/docs/html/ | ||
/laminas-mkdoc-theme.tgz | ||
/laminas-mkdoc-theme/ | ||
/vendor/ | ||
/.phpcs-cache | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Laminas\Cache\Storage\Adapter; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class RedisAuthenticationInfo | ||
{ | ||
/** | ||
* @param non-empty-string|null $username | ||
* @param non-empty-string $password | ||
*/ | ||
private function __construct( | ||
private readonly string|null $username, | ||
private readonly string $password, | ||
) { | ||
} | ||
|
||
public static function fromOptions(RedisClusterOptions|RedisOptions $options): self|null | ||
{ | ||
$username = $options->getUser(); | ||
$password = $options->getPassword(); | ||
|
||
if ($password === null || $password === '') { | ||
return null; | ||
} | ||
|
||
if ($username === null || $username === '') { | ||
return new self(null, $password); | ||
} | ||
|
||
return new self($username, $password); | ||
} | ||
|
||
/** | ||
* @see https://github.com/phpredis/phpredis/blob/4cd3f59356582a65aec1cceed44741bd5d161d9e/library.c#L4382 | ||
* | ||
* @return array{0:non-empty-string,1?:non-empty-string} | ||
*/ | ||
public function toRedisAuthInfo(): array | ||
{ | ||
if ($this->username === null) { | ||
return [$this->password]; | ||
} | ||
|
||
return [$this->username, $this->password]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.