PHP Queue System: Manage circular job queues stored in Redis

Recommend this page to a friend!
  Info   View files Documentation   View files View files (27)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 55 All time: 9,866 This week: 196Up
Version License PHP version Categories
circular-queue 1.0MIT/X Consortium ...7Databases, Utilities and Tools, Data ..., P...
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  
Name: Insolita <contact>
Classes: 7 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 5x

 

Details

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  
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

  Files folder image Files  /  src  
File Role Description
Files folder imageBehaviors (2 files)
Files folder imageContracts (5 files)
Files folder imageConverters (2 files)
Files folder imageMixins (1 file)
Files folder imageStorage (2 files)
  Plain text file CircularQueue.php Class Class source
  Plain text file Manager.php Class Class source
  Plain text file SimpleCircularQueue.php Class Class source

  Files folder image Files  /  src  /  Behaviors  
File Role Description
  Plain text file OnEmptyQueueException.php Class Class source
  Plain text file OnEmptyQueueResumeException.php Class Class source

  Files folder image Files  /  src  /  Contracts  
File Role Description
  Plain text file DelayingInterface.php Class Class source
  Plain text file EmptyQueueBehaviorInterface.php Class Class source
  Plain text file PayloadConverterInterface.php Class Class source
  Plain text file QueueInterface.php Class Class source
  Plain text file StorageInterface.php Class Class source

  Files folder image Files  /  src  /  Converters  
File Role Description
  Plain text file AsIsConverter.php Class Class source
  Plain text file SerializableConverter.php Class Class source

  Files folder image Files  /  src  /  Mixins  
File Role Description
  Plain text file DelayingTrait.php Class Class source

  Files folder image Files  /  src  /  Storage  
File Role Description
  Plain text file PhpRedisStorage.php Class Class source
  Plain text file PredisStorage.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageFunctional (3 files)
Files folder imageUnit (5 files)

  Files folder image Files  /  tests  /  Functional  
File Role Description
  Plain text file FunctionalPredisTest.php Class Class source
  Plain text file FunctionalRedisTest.php Class Class source
  Plain text file StorageSameTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  
File Role Description
  Plain text file CircularQueueTest.php Class Class source
  Plain text file ManagerTest.php Class Class source
  Plain text file SerializableConverterTest.php Class Class source
  Plain text file SimpleCircularQueueTest.php Class Class source
  Plain text file StorageTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:55
This week:0
All time:9,866
This week:196Up

For more information send a message to info at phpclasses dot org.