Beispiel #1
0
 /**
  * Enter streaming mode.
  *
  * This mode is an extension to the pipeline mode, optimized for performance. It also buffers the
  * commands on the client-side and sends them in one batch. The difference is that all results are
  * discarded, although some implementations may choose to return them anyways. This allows us to
  * apply some optimizations which make the execution of the commands significantly faster (up to
  * 50%). It's obviously only useful for bulk writing operations.
  *
  * This mode is an extension to the default Redis API, the name of the method may also change in
  * the future (batchWrite?, bulkWrite?). This mode may also implement more performance optimizing
  * features later on.
  *
  * @see multi()
  * @return bool
  */
 public function stream()
 {
     try {
         // no need to set the flag as we never read it
         return $this->client->stream();
     } catch (Exception $e) {
         return $this->handleException($e, __FUNCTION__, func_get_args());
     }
 }
 public function testBatchCommandsAreNotSentTwice()
 {
     $this->redis->del('testBatchCommand');
     $this->assertTrue($this->redis->stream());
     $this->assertTrue($this->redis->incr('testBatchCommand'));
     $this->assertSame([], $this->redis->exec());
     $this->assertEquals(1, $this->redis->get('testBatchCommand'));
     $this->assertEquals(2, $this->redis->incr('testBatchCommand'));
     $this->assertTrue($this->redis->stream());
     $this->assertTrue($this->redis->incr('testBatchCommand'));
     $this->assertSame([], $this->redis->exec());
     $this->assertEquals(3, $this->redis->get('testBatchCommand'));
 }