public function pop($topic, $timeout = PHP_INT_MAX)
{
if (!isset($this->_topicKeys[$topic])) {
$keys = [];
foreach ($this->_priorities as $priority) {
$keys[] = $this->_prefix . $topic . ':' . $priority;
}
$this->_topicKeys[$topic] = $keys;
}
if ($timeout === 0) {
foreach ($this->_topicKeys[$topic] as $key) {
$r = $this->redis->rPop($key);
if ($r !== false) {
return $r;
}
}
return false;
} else {
/** @noinspection PhpMethodParametersCountMismatchInspection */
$r = $this->redis->brPop($this->_topicKeys[$topic], $timeout);
return isset($r[1]) ? $r[1] : false;
}
}