RedisClusterNodeProxy.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Cache\Traits;
  11. /**
  12. * This file acts as a wrapper to the \RedisCluster implementation so it can accept the same type of calls as
  13. * individual \Redis objects.
  14. *
  15. * Calls are made to individual nodes via: RedisCluster->{method}($host, ...args)'
  16. * according to https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#directed-node-commands
  17. *
  18. * @author Jack Thomas <jack.thomas@solidalpha.com>
  19. *
  20. * @internal
  21. */
  22. class RedisClusterNodeProxy
  23. {
  24. private $host;
  25. private $redis;
  26. /**
  27. * @param \RedisCluster|RedisClusterProxy $redis
  28. */
  29. public function __construct(array $host, $redis)
  30. {
  31. $this->host = $host;
  32. $this->redis = $redis;
  33. }
  34. public function __call(string $method, array $args)
  35. {
  36. return $this->redis->{$method}($this->host, ...$args);
  37. }
  38. public function scan(&$iIterator, $strPattern = null, $iCount = null)
  39. {
  40. return $this->redis->scan($iIterator, $this->host, $strPattern, $iCount);
  41. }
  42. public function getOption($name)
  43. {
  44. return $this->redis->getOption($name);
  45. }
  46. }