示例#1
0
 /**
  * {@inheritdoc}
  */
 public function getItemCount()
 {
     $this->initializeRedis();
     if ($this->itemCount === null) {
         $key = $this->getKeyForItemList();
         $this->itemCount = $this->redis->llen($key);
     }
     return $this->itemCount;
 }
 /**
  *
  */
 private function handleBufferedEvents()
 {
     $length = $this->redis->llen(self::BUFFER_LIST_KEY);
     $webHookData = [];
     for ($i = 0; $i < $length; $i++) {
         $event = $this->redis->rpop(self::BUFFER_LIST_KEY);
         $webHookData[] = json_decode($event, true);
     }
     $this->webHookApi->execute(WebHookEnum::HOST_MESSENGER_ONLINE_STATE_CHANGED, $webHookData);
 }
示例#3
0
 protected function run($urlMethod, $runMethod)
 {
     $this->getSize();
     // 从redis拿出数据,并定义url,随后开始爬行逻辑
     while (static::$count < $this->endCounts) {
         if ($len = $this->redis->llen('usernames')) {
             for ($i = 0; $i < $len; $i++) {
                 Crawler::$urlMethod($this->redis->lpop('usernames'));
                 if (!$this->{$runMethod}()) {
                     continue;
                 }
             }
             static::$count++;
         } else {
             $this->getUsernames(static::$count * $this->size);
         }
     }
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function flushQueue(\Swift_Transport $transport, &$failedRecipients = null)
 {
     if (!$this->redis->llen($this->key)) {
         return 0;
     }
     if (!$transport->isStarted()) {
         $transport->start();
     }
     $failedRecipients = (array) $failedRecipients;
     $count = 0;
     $time = time();
     while ($message = unserialize($this->redis->lpop($this->key))) {
         $count += $transport->send($message, $failedRecipients);
         if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) {
             break;
         }
         if ($this->getTimeLimit() && time() - $time >= $this->getTimeLimit()) {
             break;
         }
     }
     return $count;
 }
示例#5
0
 /**
  * @param string $queueName
  * @return int
  */
 public function count($queueName)
 {
     return $this->predis->llen($queueName);
 }
 /**
  * Count messages in the queue
  *
  * @return integer
  */
 public function count()
 {
     $count = $this->client->llen("queue:{$this->name}:messages");
     return $count;
 }
示例#7
0
文件: Queue.php 项目: slaszu/redismq
 /**
  * @return int
  */
 public function getLength()
 {
     return $this->client->llen($this->getName());
 }
示例#8
0
 /**
  * @param $key
  * @return bool
  */
 public function existsList($key)
 {
     return $this->existsKey($key) && $this->redis->llen($key);
 }
示例#9
0
 /**
  * @param string $queueName
  * @return mixed
  */
 public function count($queueName)
 {
     /** @noinspection PhpUndefinedMethodInspection */
     return $this->predis->llen($queueName);
 }