加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

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

/**

  • Handles responses for all stat methods.
  • @param boolean $decode Whether to decode data before returning it or not. Default is true.
  • @return array|string|boolean false on error otherwise statistical data.
    */
    protected function _statsRead($decode = true) {
    $status = strtok($this->_read(),' ');
switch ($status) {
  case 'OK':
    $data = $this->_read((integer) strtok(' '));
    return $decode ? $this->_decode($data) : $data;
  default:
    $this->_error($status);
    return false;
}

}

/**

  • Decodes YAML data. This is a super naive decoder which just works on
  • a subset of YAML which is commonly returned by beanstalk.
  • @param string $data The data in YAML format,can be either a list or a dictionary.
  • @return array An (associative) array of the converted data.
    */
    protected function _decode($data) {
    $data = array_slice(explode("n",$data),1);
    $result = [];
foreach ($data as $key => $value) {
  if ($value[0] === '-') {
    $value = ltrim($value,'- ');
  } elseif (strpos($value,':') !== false) {
    list($key,$value) = explode(':',$value);
    $value = ltrim($value,' ');
  }
  if (is_numeric($value)) {
    $value = (integer) $value == $value ? (integer) $value : (float) $value;
  }
  $result[$key] = $value;
}
return $result;

}
}

?>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

(编辑:云计算网_泰州站长网)

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

热点阅读