PHP code example of rpq / client

1. Go to this page and download the library: Download rpq/client 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/ */

    

rpq / client example snippets


// Create a new Redis instance
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);

// Create a new client object
$client = new RQP\Client($redis);
//$rpq = new RPQ\Client($redis, 'namespace');

// Returns the queue object for interaction
$queue = $client->getQueue();
// $queue = $client->getQueue('another-queue-name');

// Push a new task called `Ping` to the priority queue with the default priority
$queue->push('Ping');

// Alternatively, we can specify args, the queue name, a different priority, and whether or not RQP-Server should attempt to retry the job if it fails.
$args = [
    'arg1',
    'arg2' => [
        'stuff' => 1,
        'more' => false,
        'foo' => 'bar'
    ],
    'arg3' => true
];
$retry = true;
$priority = 3;

// Push a new task onto the priority queue, get a UUIDv4 JobID back in response
$job = $queue->push('Worker', $args, $retry, $priority);

$at = \strtotime('+1 hour');

$job = $queue->push('Worker', $args, $retry, $priority, $at);

$queue->getStats()->get();