PHP code example of fsth / beanstalkd-cluster

1. Go to this page and download the library: Download fsth/beanstalkd-cluster library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fsth / beanstalkd-cluster example snippets


$configs = array(
    array(
        'name' => 'test1',
        'tubeNames' => array('tubeName1', 'tubeName2'),
        'hosts' => array(
            array('host' => '127.0.0.1', 'port' => '11300'),
        )
    ),
    array(
        'name' => 'test2',
        'tubeNames' => array('tubeName3', 'tubeName4'),
        'hosts' => array(
            array('host' => '127.0.0.1', 'port' => '11301'),
            array('host' => '127.0.0.1', 'port' => '11302'),
        )
    )
);
$proxy = new \FSth\BeanstalkdCluster\Business\Proxy();
$proxy->initWithConfig($configs);

$host = $proxy->lookup('tubeName1'); // return array('host','port') port in ('11300');

$host = $proxy->lookup('tubeName3'); // return array('host','port') port in ('11301', '11302');