public function testMixingMultiAndPipeline() { $this->redis->multi(); try { $this->redis->pipeline(); $this->fail('Going from multi to pipeline mode should have thrown an exception'); } catch (MultiModeException $e) { // everything is fine here } try { // make sure multi mode is disabled $this->redis->discard(); } catch (MultiModeException $e) { // disregard } $this->redis->pipeline(); try { $this->redis->multi(); $this->fail('Going from pileline to multi mode should have thrown an exception'); } catch (MultiModeException $e) { // everything is fine here } try { // make sure multi mode is disabled $this->redis->discard(); } catch (MultiModeException $e) { // disregard } }
/** * Enter transactional multi mode. * * After calling multi() all following commands will be queued on the server and only executed * once exec() is called as a single atomic transaction. All results then arrive in a single batch. * * @return bool whether or not the transaction start was successful * @link http://redis.io/commands/multi * @example * <pre> * $redis->multi(); * $redis->set('key1', 'val1'); * $redis->get('key1'); * $redis->set('key2', 'val2'); * $redis->get('key2'); * $ret = $redis->exec(); * * //$ret == array ( * // 0 => TRUE, * // 1 => 'val1', * // 2 => TRUE, * // 3 => 'val2'); * </pre> */ public function multi() { try { // no need to set the flag as we never read it return $this->client->multi(); } catch (Exception $e) { return $this->handleException($e, __FUNCTION__, func_get_args()); } }