加入收藏 | 设为首页 | 会员中心 | 我要投稿 网站开发网_安阳站长网 (https://www.0518zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

php-beanstalkd消息队列类实例分享

发布时间:2021-01-28 13:24:41 所属栏目:站长百科 来源:网络整理
导读:副标题#e# 本文实例为大家分享了php beanstalkd消息队列类的具体代码,供大家参考,具体内容如下 use RuntimeException; /** An interface to the beanstalk queue service. Implements the beanstalk protocol spec 1.9. Where appropriate the documentat

/**

  • The use command is for producers. Subsequent put commands will put
  • jobs into the tube specified by this command. If no use command has
  • been issued,jobs will be put into the tube named default.
  • @param string $tube A name at most 200 bytes. It specifies the tube to
  • use. If the tube does not exist,it will be created.
  • @return string|boolean false on error otherwise the name of the tube.
    */
    public function useTube($tube) {
    $this->_write(sprintf('use %s',$tube));
    $status = strtok($this->_read(),' ');
switch ($status) {
  case 'USING':
    return strtok(' ');
  default:
    $this->_error($status);
    return false;
}

}

/**

  • Pause a tube delaying any new job in it being reserved for a given time.
  • @param string $tube The name of the tube to pause.
  • @param integer $delay Number of seconds to wait before reserving any more
  • jobs from the queue.
  • @return boolean false on error otherwise true.
    */
    public function pauseTube($tube,$delay) {
    $this->_write(sprintf('pause-tube %s %d',$tube,$delay));
    $status = strtok($this->_read(),' ');
switch ($status) {
  case 'PAUSED':
    return true;
  case 'NOT_FOUND':
  default:
    $this->_error($status);
    return false;
}

}

/ Worker Commands /

(编辑:网站开发网_安阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!