/** * {@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); }
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); } } }
/** * {@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; }
/** * @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; }
/** * @return int */ public function getLength() { return $this->client->llen($this->getName()); }
/** * @param $key * @return bool */ public function existsList($key) { return $this->existsKey($key) && $this->redis->llen($key); }
/** * @param string $queueName * @return mixed */ public function count($queueName) { /** @noinspection PhpUndefinedMethodInspection */ return $this->predis->llen($queueName); }