Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (27) | Download .zip | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 55 | All time: 9,866 This week: 196 |
Version | License | PHP version | Categories | |||
circular-queue 1.0 | MIT/X Consortium ... | 7 | Databases, Utilities and Tools, Data ..., P... |
Description | Author | |
This package can manage circular job queues stored in Redis. |
|
Circular Queue with redis implementation for distribution of shared data Useful for resource balancing, parsing
composer require insolita/circular-queue
$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
...
$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
$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 |
File | Role | Description | ||
---|---|---|---|---|
src (3 files, 5 directories) | ||||
tests (2 directories) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
Behaviors (2 files) | ||||
Contracts (5 files) | ||||
Converters (2 files) | ||||
Mixins (1 file) | ||||
Storage (2 files) | ||||
CircularQueue.php | Class | Class source | ||
Manager.php | Class | Class source | ||
SimpleCircularQueue.php | Class | Class source |
Files | / | src | / | Behaviors |
File | Role | Description |
---|---|---|
OnEmptyQueueException.php | Class | Class source |
OnEmptyQueueResumeException.php | Class | Class source |
Files | / | src | / | Contracts |
File | Role | Description |
---|---|---|
DelayingInterface.php | Class | Class source |
EmptyQueueBehaviorInterface.php | Class | Class source |
PayloadConverterInterface.php | Class | Class source |
QueueInterface.php | Class | Class source |
StorageInterface.php | Class | Class source |
Files | / | src | / | Converters |
File | Role | Description |
---|---|---|
AsIsConverter.php | Class | Class source |
SerializableConverter.php | Class | Class source |
Files | / | src | / | Storage |
File | Role | Description |
---|---|---|
PhpRedisStorage.php | Class | Class source |
PredisStorage.php | Class | Class source |
Files | / | tests | / | Functional |
File | Role | Description |
---|---|---|
FunctionalPredisTest.php | Class | Class source |
FunctionalRedisTest.php | Class | Class source |
StorageSameTest.php | Class | Class source |
Files | / | tests | / | Unit |
File | Role | Description |
---|---|---|
CircularQueueTest.php | Class | Class source |
ManagerTest.php | Class | Class source |
SerializableConverterTest.php | Class | Class source |
SimpleCircularQueueTest.php | Class | Class source |
StorageTest.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.