Esempio n. 1
0
 public function __call($name, $args)
 {
     if (strtolower($name) == 'on' && isset($args[0])) {
         $this->_rediska->on($args[0]);
         $this->_oneTimeConnection = $this->_specifiedConnection->getConnection();
         return $this;
     }
     if ($this->_oneTimeConnection) {
         $connection = $this->_oneTimeConnection;
         $this->_oneTimeConnection = null;
     } else {
         $connection = $this->_defaultConnection;
     }
     if ($connection !== null) {
         $this->_specifiedConnection->setConnection($connection);
     } else {
         $this->_specifiedConnection->resetConnection();
     }
     $command = $this->_rediska->getCommand($name, $args);
     if (!$command->isAtomic()) {
         throw new Rediska_Exception("Command '{$name}' doesn't work properly (not atomic) in pipeline on multiple servers");
     }
     $this->_commands[] = $command;
     $this->_specifiedConnection->resetConnection();
     return $this;
 }
Esempio n. 2
0
 /**
  * Call Redis command
  * 
  * @param string $name Command name
  * @param array $args  Command arguments
  * @return mixin
  */
 public function __call($name, $args)
 {
     $this->_specifiedConnection->resetConnection();
     $command = $this->getCommand($name, $args);
     $command->write();
     return $command->read();
 }
Esempio n. 3
0
 /**
  * Execute command
  *
  * @param string $name Command name
  * @param array  $args  Command arguments
  * @return mixed
  */
 protected function _executeCommand($name, $args = array())
 {
     $this->_specifiedConnection->resetConnection();
     $command = Rediska_Commands::get($this, $name, $args);
     $response = $command->execute();
     unset($command);
     return $response;
 }
Esempio n. 4
0
 /**
  * Add command to transaction
  *
  * @param string $name Command name
  * @param array  $args Arguments
  * @return Rediska_Transaction
  */
 protected function _addCommand($name, $args = array())
 {
     $this->_specifiedConnection->setConnection($this->_connection);
     $command = Rediska_Commands::get($this->_rediska, $name, $args);
     $command->initialize();
     if (!$command->isAtomic()) {
         throw new Rediska_Exception("Command '{$name}' doesn't work properly (not atomic) in transaction on multiple servers");
     }
     $this->_commands[] = $command;
     $this->_specifiedConnection->resetConnection();
     return $this;
 }
Esempio n. 5
0
 /**
  * Add command to transaction
  *
  * @param string $name Command name
  * @param array  $args Arguments
  * @return Rediska_Transaction
  */
 protected function _addCommand($name, $args = array())
 {
     $this->start();
     $this->_specifiedConnection->setConnection($this->_connection);
     $command = Rediska_Commands::get($this->_rediska, $name, $args);
     if (!$command->isAtomic()) {
         throw new Rediska_Exception("Command '{$name}' doesn't work properly (not atomic) in pipeline on multiple servers");
     }
     $command->execute();
     if (!$command->isQueued()) {
         throw new Rediska_Transaction_Exception("Command not added to transaction!");
     }
     $this->_commands[] = $command;
     $this->_specifiedConnection->resetConnection();
     return $this;
 }
Esempio n. 6
0
 /**
  * Add command to pipeline
  *
  * @param string $name Command name
  * @param array  $args Arguments
  * @return Rediska_Pipeline
  */
 protected function _addCommand($name, $args = array())
 {
     if ($this->_oneTimeConnection) {
         $connection = $this->_oneTimeConnection;
         $this->_oneTimeConnection = null;
     } else {
         $connection = $this->_defaultConnection;
     }
     if ($connection !== null) {
         $this->_specifiedConnection->setConnection($connection);
     } else {
         $this->_specifiedConnection->resetConnection();
     }
     $command = Rediska_Commands::get($this->_rediska, $name, $args);
     if (!$command->isAtomic()) {
         throw new Rediska_Exception("Command '{$name}' doesn't work properly (not atomic) in pipeline on multiple servers");
     }
     $this->_commands[] = $command;
     $this->_specifiedConnection->resetConnection();
     return $this;
 }