123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace Predis\Command\Processor;
- use Predis\Command\CommandInterface;
- use Predis\Command\PrefixableCommandInterface;
- class KeyPrefixProcessor implements CommandProcessorInterface
- {
- private $prefix;
-
- public function __construct($prefix)
- {
- $this->setPrefix($prefix);
- }
-
- public function setPrefix($prefix)
- {
- $this->prefix = $prefix;
- }
-
- public function getPrefix()
- {
- return $this->prefix;
- }
-
- public function process(CommandInterface $command)
- {
- if ($command instanceof PrefixableCommandInterface && $command->getArguments()) {
- $command->prefixKeys($this->prefix);
- }
- }
-
- public function __toString()
- {
- return $this->getPrefix();
- }
- }
|