本文整理匯總了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);
}