Home >Backend Development >PHP Tutorial >php运用beanstalkd 过程分享

php运用beanstalkd 过程分享

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 10:40:18982browse

php使用beanstalkd 过程分享
一、安装
1、安装libevent

引用
wget http://cloud.github.com/downloads/libevent/libevent/libevent-1.4.14b-stable.tar.gz
cp libevent-1.4.14b-stable.tar.gz /usr/local/src/
tar zxvf libevent-1.4.14b-stable.tar.gz
cd  libevent-1.4.14b-stable
./configure --prefix=/usr/local/libevent
make
make install

2、安装beanstalkd(本文提供附件)
引用

cp beanstalkd-1.4.6.tar.gz /usr/local/src/
tar zxvf beanstalkd-1.4.6.tar.gz
cd  beanstalkd-1.4.6
./configure --prefix=/usr/local/beanstalkd
make
make install
./beanstalkd -d -l 127.0.0.1 -p 11300

3、php客户端的使用,建议采用源码的方式,不用扩展的方式。
  http://sourceforge.net/projects/beanstalk/ 下载php客户端代码
引用

    require('./BeanStalk.class.php');
    $beanstalk = BeanStalk::open(array(
        'servers'       => array( '127.0.0.1:11300' ),
        'select'        => 'random peek'
    ));  
    $beanstalk->use_tube('foo');
    $beanstalk->put(0, 0, 120, 'say hello world');         
    $beanstalk->watch('foo');
    $job = $beanstalk->reserve_with_timeout();
    echo $job->get();                  // Output: 'say hello world'   
    Beanstalk::delete($job);                    // Delete the job.
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn