PHP code example of oktopost / deep-queue

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

    

oktopost / deep-queue example snippets


$deepQueue = new DeepQueue();

$deepQueue->config()
		->setConnectorPlugin(Connectors::Redis(['prefix' => 'demo.queue']))
		->setManagerPlugin(Managers::MySQL(['user' => 'root', 'db' => 'demo_queue']))
		->setSerializer(DefaultSerializer::get())
		->addLogProvider(new FileLogProvider(__DIR__));

//or using prepared configuration
$deepQueue = PreparedQueue::RedisMySQL(['prefix' => 'demo.queue'], 
    ['user' => 'root', 'db' => 'demo_queue']);

$deepQueue->config()
		->addLogProvider(new FileLogProvider(__DIR__));

//creating and setting up new queue object
$queueObject = new QueueObject();
$queueObject->Name = 'demo.queue';
$queueObject->Config = new QueueConfig();
$queueObject->Config->DelayPolicy = Policy::ALLOWED;

$deepQueue->config()
	->manager()
	->create($queueObject);

//loading existing queue object
$queueObject = $deepQueue->getQueueObject('demo.queue');

//get connector
$queue = $deepQueue->get('demo.queue');

//enqueue data
$payload = new Payload('payload data');

$queue->enqueue($payload);

//or
$payload = new Payload('payload data');
$payload2 = new Payload('payload data2');

$queue->enqueueAll([$payload, $payload2]);


//dequeue data
$payloads = $queue->dequeue(255);