当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::blpop方法代码示例

本文整理汇总了PHP中Predis\Client::blpop方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::blpop方法的具体用法?PHP Client::blpop怎么用?PHP Client::blpop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Predis\Client的用法示例。


在下文中一共展示了Client::blpop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * Get a job from queue.
  * This call is blocking.
  *
  * @param string $key
  * @param int    $timeout
  *
  * @return string|null
  */
 public function get($key, $timeout = 30)
 {
     if ($this->checkConnection()) {
         $return = $this->predis->blpop(array(self::QUEUE_PREFIX . ':' . QueuePriority::PRIORITY_HIGH . ':' . $key, self::QUEUE_PREFIX . ':' . QueuePriority::PRIORITY_NORMAL . ':' . $key, self::QUEUE_PREFIX . ':' . QueuePriority::PRIORITY_LOW . ':' . $key), $timeout);
         if (is_array($return)) {
             return $return[1];
         }
     }
     return null;
 }
开发者ID:gerifield,项目名称:little-red-queue,代码行数:19,代码来源:LittleRedQueue.php

示例2: waitToAssignTask

 /**
  * @throws QueueException
  * @throws \Exception
  * @return Task
  */
 public function waitToAssignTask()
 {
     $this->setActive();
     // A nil multi-bulk when no element could be popped and the timeout expired.
     // A two-element multi-bulk with the first element being the name of the key
     // where an element was popped and the second element being the value of
     // the popped element.
     $redisData = $this->redisClient->blpop($this->announceListKey, 5);
     //Pop timed out rather than got a task
     if ($redisData === null) {
         return null;
     }
     list(, $taskKey) = $redisData;
     $serializedTask = $this->redisClient->get($this->taskListKey . $taskKey);
     if (!$serializedTask) {
         $data = var_export($serializedTask, true);
         throw new \Exception("Failed to find expected task " . $taskKey . ". Data returned was " . $data);
     }
     $task = @unserialize($serializedTask);
     if ($task == false) {
         $this->setStatus($taskKey, TaskQueue::STATE_ERROR);
         throw new QueueException("Failed to unserialize string {$serializedTask}");
     }
     $this->setStatus($task, TaskQueue::STATE_WORKING);
     return $task;
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:31,代码来源:RedisTaskQueue.php

示例3: receiveMessage

 public function receiveMessage($queueId = null, $waitTime = 0)
 {
     $queueId = $this->normaliseQueueId($queueId);
     if (empty($waitTime)) {
         $waitTime = $this->waitTime;
     }
     $message = $this->predis->blpop([$queueId], $waitTime);
     if (empty($message[1])) {
         return null;
     }
     /** @var QueueMessage $queueMessage */
     $queueMessage = $this->messageFactory->createMessage($message[1], $queueId);
     $index = $this->receivedMessageCounter++;
     $this->receivedMessages[$index] = $queueMessage;
     $queueMessage->setReceiptId($index);
     return $queueMessage;
 }
开发者ID:silktide,项目名称:queueball-redis,代码行数:17,代码来源:Queue.php

示例4: readCommandReply

 /**
  * @param string $commandIdentifier
  * @param int $timeout
  * @return array
  */
 public function readCommandReply($commandIdentifier, $timeout = null)
 {
     $timeout = $timeout ? $timeout : $this->timeout;
     return $this->client->blpop([sprintf(self::COMMAND_RESPONSE_KEY, $commandIdentifier)], $timeout);
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:10,代码来源:RedisTemplate.php


注:本文中的Predis\Client::blpop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。