當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::lpop方法代碼示例

本文整理匯總了PHP中Predis\Client::lpop方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::lpop方法的具體用法?PHP Client::lpop怎麽用?PHP Client::lpop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Predis\Client的用法示例。


在下文中一共展示了Client::lpop方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: subscribe

 /**
  * Show the asynchronous client logs in the main process logger (console)
  *
  * @return string|null
  *
  * @throws \RuntimeException
  */
 public static function subscribe()
 {
     if (!isset(self::$redisClient)) {
         throw new \RuntimeException('Redis client has not been initialised');
     }
     while (null != ($log = self::$redisClient->lpop(ConfigurationLoader::get('client.async.redis.key') . '.client.logs'))) {
         list($level, $message) = explode('|', $log);
         self::$logger->addRecord($level, $message);
     }
 }
開發者ID:phxlol,項目名稱:lol-php-api,代碼行數:17,代碼來源:LoggerFactory.php

示例2: consume

 /**
  * @param string $queue
  */
 public function consume($queue)
 {
     $value = $this->client->lpop($queue);
     if ($value === null) {
         return;
     }
     $decoded = json_decode($value, true);
     $command = call_user_func($this->resolver, $decoded['command']);
     $command->withOptions($decoded['options'])->execute();
 }
開發者ID:equip,項目名稱:redis-queue,代碼行數:13,代碼來源:Consumer.php

示例3: getAssociation

 /**
  * Read association from Redis. If no handle given 
  * and multiple associations found, returns latest issued
  */
 function getAssociation($server_url, $handle = null)
 {
     // simple case: handle given
     if ($handle !== null) {
         return $this->getAssociationFromServer($this->associationKey($server_url, $handle));
     }
     // no handle given, receiving the latest issued
     $serverKey = $this->associationServerKey($server_url);
     $lastKey = $this->redis->lpop($serverKey);
     if (!$lastKey) {
         return null;
     }
     // get association, return null if failed
     return $this->getAssociationFromServer($lastKey);
 }
開發者ID:Stony-Brook-University,項目名稱:doitsbu,代碼行數:19,代碼來源:PredisStore.php

示例4: run

 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);
         }
     }
 }
開發者ID:AnnatarHe,項目名稱:zhihuCrawler,代碼行數:18,代碼來源:Controller.php

示例5: pop

 /**
  * @inheritdoc
  */
 public function pop($queue)
 {
     foreach ([':delayed', ':reserved'] as $type) {
         $options = ['cas' => true, 'watch' => $queue . $type];
         $this->redis->transaction($options, function (MultiExec $transaction) use($queue, $type) {
             $data = $this->redis->zrangebyscore($queue . $type, '-inf', $time = time());
             if (!empty($data)) {
                 $transaction->zremrangebyscore($queue . $type, '-inf', $time);
                 $transaction->rpush($queue, $data);
             }
         });
     }
     $data = $this->redis->lpop($queue);
     if ($data === null) {
         return false;
     }
     $this->redis->zadd($queue . ':reserved', [$data => time() + $this->expire]);
     $data = Json::decode($data);
     return ['id' => $data['id'], 'body' => $data['body'], 'queue' => $queue];
 }
開發者ID:Nuffic,項目名稱:yii2-queue-1,代碼行數:23,代碼來源:RedisQueue.php

示例6: flushQueue

 /**
  * {@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;
 }
開發者ID:jayesbe,項目名稱:SncRedisBundle,代碼行數:25,代碼來源:RedisSpool.php

示例7: getCounters

 /**
  * @param int $max
  * @return array
  */
 public function getCounters($max = 30)
 {
     $counters = [];
     $number = 0;
     while (true) {
         $redisData = $this->redisClient->lpop($this->getCounterKey());
         if (!$redisData) {
             break;
         }
         $counter = unserialize($redisData);
         $counters[] = $counter;
         $number++;
         if ($number >= $max) {
             break;
         }
     }
     return $counters;
 }
開發者ID:atawsports2,項目名稱:Imagick-demos,代碼行數:22,代碼來源:AsyncStats.php


注:本文中的Predis\Client::lpop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。