当前位置: 首页>>代码示例>>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;未经允许,请勿转载。