Download the PHP package darkjest/deferq without Composer
On this page you can find all versions of the php package darkjest/deferq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download darkjest/deferq
More information about darkjest/deferq
Files in darkjest/deferq
Package deferq
Short Description Async task manager with deduplication, result caching and callback notifications
License MIT
Homepage https://github.com/DarkJest/DeferQ
Informations about the package deferq
DeferQ
Документация на русском (README.ru.md)
Async task manager for PHP 8.4 with built-in deduplication, result caching (PSR-16), and callback notifications. Submit heavy tasks (report generation, data exports, etc.), and DeferQ will ensure each unique task runs only once, cache results for subsequent requests, and notify your application when work is done.
Installation
For Redis queue support:
For RabbitMQ queue support:
Quick Start
1. Configure DeferQ
2. Register Task Handlers
3. Dispatch a Task
4. Poll for Status
5. Run the Worker
Or use the CLI worker:
Deduplication
DeferQ prevents duplicate execution of identical tasks using fingerprinting:
- When you call
dispatch(), DeferQ generates a SHA-256 fingerprint from the task name and canonically sorted parameters. - If a result for this fingerprint already exists in cache, it returns immediately with
TaskStatus::Completed. - If a task with this fingerprint is already pending or running, the existing task's receipt is returned — no new task is created.
- Only if no cached result and no active task exist, a new task is created and queued.
This means 100 users requesting the same report simultaneously will trigger only a single execution.
Parameter key ordering does not matter — ['a' => 1, 'b' => 2] and ['b' => 2, 'a' => 1] produce the same fingerprint.
Callbacks
Callbacks are invoked by the worker after a task completes and its result is saved to cache. Implement CallbackInterface for production use:
Chain multiple callbacks with CallbackChain:
Callback failures are caught and logged — they never crash the worker.
Custom Queue Adapter
Implement QueueAdapterInterface to use any queue backend:
CLI Worker Bootstrap
Create a worker-bootstrap.php file that returns a configured Worker instance:
Then run:
Signal Handling
The CLI worker handles SIGTERM and SIGINT for graceful shutdown. When a signal is received, the worker finishes processing the current task before exiting.
Author
DarkJest
License
MIT
All versions of deferq with dependencies
psr/simple-cache Version ^3.0
psr/log Version ^3.0
ramsey/uuid Version ^4.7