Download the PHP package lpks/redis-queue without Composer
On this page you can find all versions of the php package lpks/redis-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package redis-queue
Install
Usage
Worker (Consumer)
Process messages from the queue:
Queue (Producer)
Push messages into the queue:
API Reference
Client class
Constructor
$options— Additional Redis options (e.g.password,database,prefix,scheme)
Methods
| Method | Description |
|---|---|
push(string $name, array $data, int $retries = 3) |
Push a message to the queue, auto-retry on Redis error |
loop(string $name, Worker $worker) |
Infinite loop processing messages, auto-reconnect on disconnection |
stop() |
Stop the processing loop |
enableGracefulShutdown() |
Catch SIGTERM/SIGINT to shut down safely (requires ext-pcntl) |
setLogger(callable $logger) |
Inject a custom logger (e.g. function($msg) { echo $msg; }) |
setOnIdle(callable $onIdle) |
Called on every empty poll with the number of seconds idle so far; return true to stop the loop |
Constants
| Constant | Default | Description |
|---|---|---|
Client::BLOCK_TIMEOUT |
2 |
How long BLPOP waits for a message each poll |
Client::READ_WRITE_TIMEOUT |
5 |
Socket read timeout. Must be non-zero (otherwise a silently dead connection blocks forever) and greater than BLOCK_TIMEOUT (otherwise every poll times out). Override per instance via the read_write_timeout option. |
Exiting when the queue is empty
A worker that blocks on BLPOP forever keeps its memory for as long as it runs. Use
setOnIdle() to let the process exit once there is nothing left to do — useful when a
supervisor (pm2, systemd) restarts it on demand:
The idle counter resets every time a message is processed.
Advanced example: Redis with password and custom logger
Message class
| Method | Description |
|---|---|
$message->key |
Magic getter, returns value by key |
$message->get(string $key, $default = null) |
Get value with a default fallback |
$message->has(string $key): bool |
Check if a key exists |
$message->toArray(): array |
Get all data as an array |
isset($message->key) |
Check if a key exists |
All versions of redis-queue with dependencies
PHP Build Version
Package Version
The package lpks/redis-queue contains the following files
Loading the files please wait ...