PHP Classes

PHP Queue System: Manage circular job queues stored in Redis

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 61 All time: 10,489 This week: 73Up
Version License PHP version Categories
circular-queue 1.0MIT/X Consortium ...7Databases, Tools, Data types, PHP 7
Description 

Author

This package can manage circular job queues stored in Redis.

It can create queue of job data storing the details of the data properties in a Redis key-value pair database.

The package can also perform other types of operations like pushing jobs to the queue, pull the next job in the queue, getting, delaying a job that was in the queue for a given period of time, resume a delayed job, get the count of jobs in the queue, etc..

Picture of Insolita
  Performance   Level  
Innovation award
Innovation award
Nominee: 18x

 

Documentation

Circular Queue

Circular Queue with redis implementation for distribution of shared data Useful for resource balancing, parsing

Build StatusScrutinizer Code QualitySensioLabsInsight

Install

composer require insolita/circular-queue

Usage

SimpleCircularQueue

  $q = new SimpleCircularQueue(
       'queueName',
        new AsIsConverter(),              // insolita\cqueue\Contracts\PayloadConverterInterface
        new OnEmptyQueueException(),      // insolita\cqueue\Contracts\EmptyQueueBehaviorInterface
        new PredisStorage(new Client())   // insolita\cqueue\Contracts\StorageInterface
  );

  $q->fill(['alpha', 'beta', 'gamma', 'delta']);
  $q->next(); //alpha
  $q->next(); //beta
  $q->next(); //gamma
  $q->next(); //delta
  $q->next(); //alpha
  $q->next(); //beta
  $q->next(); //gamma
  $q->countQueued();//4
  $q->purgeQueued();//clear queue
  ...

CircularQueue

  $q = new CircularQueue(
       'queueName',
        new AsIsConverter(),              // insolita\cqueue\Contracts\PayloadConverterInterface
        new OnEmptyQueueException(),      // insolita\cqueue\Contracts\EmptyQueueBehaviorInterface
        new PredisStorage(new Client())   // insolita\cqueue\Contracts\StorageInterface
  );
    $q->fill(['alpha', 'beta', 'gamma', 'delta']);
    $item = $q->pull(); //alpha - extract item from queue
    $q->resume($item); // resume item in queue

    $item1 = $q->pull(60); //Item will be resumed in queue after 60 seconds
    $item2 = $q->pull();
    $q->resume($item2, 120); //Item will be resumed in queue after 120 seconds
    $item3 = $q->pull();
    $q->resumeAt($item3, time()+100500); //Item will be resumed  after concrete timestamp
    $q->countTotal()   //4
    $q->countQueued()  //1
    $q->countDelayed() //3
    $q->listDelayed()  // ['beta', 'gamma', 'delta']
    $q->resumeAllDelayed(); //Force resume all delayed in queue
    $q->purgeDelayed(); //Remove all delayed

Manager

   $q1 = new CircularQueue(
                                 'firstQueue',
                                  new SerializableConverter(),
                                  new OnEmptyQueueException(),
                                  new PhpRedisStorage(new \Redis())
                            );
   $manager = new Manager([$q1]);
   $manager->add(new CircularQueue(
                           'secondQueue',
                            new SerializableConverter(),
                            new OnEmptyQueueException(),
                            new PhpRedisStorage(new \Redis())
                      ));

   $manager->queue('firstQueue')->fill([...]);
   $manager->queue('secondQueue')->fill([...]);
   ...
   $manager->remove('firstQueue');


  Files folder image Files (27)  
File Role Description
Files folder imagesrc (3 files, 5 directories)
Files folder imagetests (2 directories)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:61
This week:0
All time:10,489
This week:73Up