Example #1
0
 /**
  * Sent upstream queue
  * @param int $throttle
  * @return int
  */
 public function sentUpstreamOperations($throttle = 100)
 {
     $chunks = array_chunk($this->operation_queue, $throttle);
     $chunk_count = count($chunks);
     $operations = 0;
     for ($c = 0; $c < $chunk_count; $c++) {
         /** @var \Predis\Pipeline\Pipeline $pipe */
         $pipe = $this->redis->command('pipeline');
         for ($op = count($chunks[$c]); $op > 0; $op--) {
             list($command, $params) = array_shift($chunks[$c]);
             call_user_func_array([$pipe, $command], $params);
             $operations++;
         }
         $pipe->execute();
     }
     $this->operation_queue = [];
     return $operations;
 }