本文整理汇总了PHP中Predis\Client::brpop方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::brpop方法的具体用法?PHP Client::brpop怎么用?PHP Client::brpop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::brpop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @param string $queueName
* @param null $timeout
* @return mixed|null
*/
public function get($queueName, $timeout = null)
{
$result = $this->predis->brpop($queueName, $timeout);
if (empty($result)) {
return null;
} else {
return unserialize($result[1]);
}
}
示例2: get
/**
* @param string $queueName
* @param null $timeout
* @return mixed|null
*/
public function get($queueName, $timeout = null)
{
/** @noinspection PhpUndefinedMethodInspection */
$result = $this->predis->brpop($queueName, $timeout);
if (empty($result)) {
return null;
} else {
return unserialize($result[1]);
}
}
示例3: waitAndTake
/**
* Wait for a message in the queue and return the message for processing
* (without safety queue)
*
* @param int $timeout
* @return \Flowpack\JobQueue\Common\Queue\Message The received message or NULL if a timeout occured
*/
public function waitAndTake($timeout = NULL)
{
if ($timeout === NULL) {
$timeout = $this->defaultTimeout;
}
$keyAndValue = $this->client->brpop("queue:{$this->name}:messages", $timeout);
$value = $keyAndValue[1];
if (is_string($value)) {
$message = $this->decodeMessage($value);
if ($message->getIdentifier() !== NULL) {
$this->client->srem("queue:{$this->name}:ids", $message->getIdentifier());
}
// The message is marked as done
$message->setState(\Flowpack\JobQueue\Common\Queue\Message::STATE_DONE);
return $message;
} else {
return NULL;
}
}
示例4: brpop
public function brpop($channel, $timeout)
{
return $this->client->brpop($channel, $timeout);
}