mirror of
https://github.com/predis/predis.git
synced 2026-08-21 10:30:56 +00:00
26 lines
705 B
PHP
26 lines
705 B
PHP
<?php
|
|
|
|
namespace Predis\Options;
|
|
|
|
use Predis\Distribution\IDistributionStrategy;
|
|
use Predis\Distribution\HashRing;
|
|
|
|
class ClientKeyDistribution extends Option {
|
|
public function validate($value) {
|
|
if ($value instanceof IDistributionStrategy) {
|
|
return $value;
|
|
}
|
|
if (is_string($value)) {
|
|
$valueReflection = new \ReflectionClass($value);
|
|
if ($valueReflection->isSubclassOf('\Predis\Distribution\IDistributionStrategy')) {
|
|
return new $value;
|
|
}
|
|
}
|
|
throw new \InvalidArgumentException('Invalid value for key distribution');
|
|
}
|
|
|
|
public function getDefault() {
|
|
return new HashRing();
|
|
}
|
|
}
|