/** * Execute command * * @param string $name * @param array $args * @return mixed */ protected function _executeCommand($name, $args = array()) { $command = Rediska_Commands::get($this->_rediska, $name, $args); $response = $command->execute(); unset($command); return $response; }
/** * 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); $command->initialize(); 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; }
/** * 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; }
/** * 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); $this->getProfiler()->start($command); $response = $command->execute(); $this->getProfiler()->stop(); unset($command); return $response; }
/** * 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; }
} function updateMethods($file, $methods) { $content = file_get_contents($file); $newContent = substr($content, 0, strpos($content, DOCBLOCK)); $newContent .= DOCBLOCK . "\n" . $methods . "\n}"; file_put_contents($file, $newContent); } // Start! require_once REDISKA; $rediskaMethods = ''; $transactionMethods = ''; $connectionMethods = ''; $pipelineMethods = ''; $count = 0; foreach (Rediska_Commands::getList() as $name => $class) { // Get name $name = lcfirst(substr($class, 16)); // Get description $classReflection = new ReflectionClass($class); $docBlockLines = explode("\n", $classReflection->getDocComment()); array_shift($docBlockLines); $description = ''; foreach ($docBlockLines as $line) { if (strpos($line, ' * @') !== false) { break; } $description .= ' ' . $line . "\n"; } $createReflection = $classReflection->getMethod('create'); $createDocBlockLines = explode("\n", $createReflection->getDocComment());