ManaPHP\Message\Queue\Adapter\Redis::pop PHP Method

pop() public method

public pop ( string $topic, integer $timeout = PHP_INT_MAX ) : string | false
$topic string
$timeout integer
return string | false
    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;
        }
    }