-
-
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 #13 from boesing/feature/redis-cluster
Feature: redis cluster support
- Loading branch information
Showing
32 changed files
with
2,406 additions
and
83 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
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,5 +1,11 @@ | ||
{ | ||
"extensions": [ | ||
"redis" | ||
"redis", | ||
"igbinary" | ||
], | ||
"ini": [ | ||
"redis.clusters.seeds = 'cluster[]=redis-cluster:6379&cluster[]=redis-cluster:6380&cluster[]=redis-cluster:6381&cluster[]=redis-cluster:6382&cluster[]=redis-cluster:6383&cluster[]=redis-cluster:6384'", | ||
"redis.clusters.timeout = 'cluster=5'", | ||
"redis.clusters.read_timeout = 'cluster=10'" | ||
] | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
45 changes: 45 additions & 0 deletions
45
src/Exception/InvalidRedisClusterConfigurationException.php
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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Laminas\Cache\Storage\Adapter\Exception; | ||
|
||
use Laminas\Cache\Exception\InvalidArgumentException; | ||
|
||
use function sprintf; | ||
|
||
final class InvalidRedisClusterConfigurationException extends InvalidArgumentException | ||
{ | ||
public static function fromMissingSeedsConfiguration(): self | ||
{ | ||
return new self('Could not find `redis.clusters.seeds` entry in the php.ini file(s).'); | ||
} | ||
|
||
public static function fromMissingSeedsForNamedConfiguration(string $name): self | ||
{ | ||
return new self(sprintf( | ||
'Missing `%s` within the configured `redis.cluster.seeds` entry in the php.ini file(s).', | ||
$name | ||
)); | ||
} | ||
|
||
public static function fromMissingRequiredValues(): self | ||
{ | ||
return new self('Missing either `name` or `seeds`.'); | ||
} | ||
|
||
public static function fromNameAndSeedsProvidedViaConfiguration(): self | ||
{ | ||
return new self('Please provide either `name` or `seeds` configuration, not both.'); | ||
} | ||
|
||
public static function fromInvalidSeedsConfiguration(string $seed): self | ||
{ | ||
return new self( | ||
sprintf( | ||
'Configured `seed` %s is invalid. Must be configured as "host:port" while separated by a colon.', | ||
$seed | ||
) | ||
); | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Laminas\Cache\Storage\Adapter\Exception; | ||
|
||
use Laminas\Cache\Exception\RuntimeException; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class MetadataErrorException extends RuntimeException | ||
{ | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Laminas\Cache\Storage\Adapter\Exception; | ||
|
||
use Laminas\Cache\Exception\RuntimeException as LaminasCacheRuntimeException; | ||
use RedisCluster; | ||
use RedisClusterException; | ||
use Throwable; | ||
|
||
final class RedisRuntimeException extends LaminasCacheRuntimeException | ||
{ | ||
public static function fromClusterException(RedisClusterException $exception, RedisCluster $redis): self | ||
{ | ||
$message = $redis->getLastError() ?? $exception->getMessage(); | ||
|
||
return new self($message, (int) $exception->getCode(), $exception); | ||
} | ||
|
||
public static function fromFailedConnection(Throwable $exception): self | ||
{ | ||
return new self( | ||
'Could not establish connection', | ||
(int) $exception->getCode(), | ||
$exception | ||
); | ||
} | ||
} |
Oops, something went wrong.