From 559c5097cda516f84a2f038c0cd696f4aed623da Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Thu, 1 Dec 2011 15:34:45 +0100 Subject: [PATCH] Add the ability to discard the commands queued in a pipeline object. --- lib/Predis/Pipeline/PipelineContext.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Predis/Pipeline/PipelineContext.php b/lib/Predis/Pipeline/PipelineContext.php index 51f10e6f..90fca566 100644 --- a/lib/Predis/Pipeline/PipelineContext.php +++ b/lib/Predis/Pipeline/PipelineContext.php @@ -106,17 +106,19 @@ class PipelineContext } /** - * Flushes the queued commands by writing the buffer to Redis and reading - * all the replies into the reply buffer. + * Flushes the buffer that holds the queued commands. * + * @param Boolean $send Specifies if the commands in the buffer should be sent to Redis. * @return PipelineContext */ - public function flushPipeline() + public function flushPipeline($send = true) { if (count($this->pipeline) > 0) { - $connection = $this->client->getConnection(); - $replies = $this->executor->execute($connection, $this->pipeline); - $this->replies = array_merge($this->replies, $replies); + if ($send) { + $connection = $this->client->getConnection(); + $replies = $this->executor->execute($connection, $this->pipeline); + $this->replies = array_merge($this->replies, $replies); + } $this->pipeline = array(); }