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; }
/** * Chain method to work with keys on specified by alias server * * @param $alias Alias or [host]:[port] of server if not specified * @return Rediska_Connection_Specified */ public function on($alias) { if (!isset($this->_connections[$alias])) { throw new Rediska_Exception("Can't find connection '{$alias}'"); } $this->_specifiedConnection->setConnection($this->_connections[$alias]); return $this->_specifiedConnection; }
/** * Chain method to work with keys on specified by alias server * * @param $aliasOrConnection Alias or Rediska_Connection object * @return Rediska_Connection_Specified */ public function on($aliasOrConnection) { if ($aliasOrConnection instanceof Rediska_Connection) { $connection = $aliasOrConnection; } else { $alias = $aliasOrConnection; $connection = $this->getConnectionByAlias($alias); } $this->_specifiedConnection->setConnection($connection); return $this->_specifiedConnection; }
/** * 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; }
/** * 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; }
/** * 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; }