php運用beanstalkd 過程分享

來源:互聯網
上載者:User
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.
?>

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.