lpks / redis-queue
v1.1.0
2023-04-13 15:55 UTC
Requires
- predis/predis: ^1.1
README
composer require lpks/redis-queue
Usage
Worker
<?php require_once __DIR__ . '/vendor/autoload.php'; use RedisQueue\Client; use RedisQueue\Message; use RedisQueue\Worker; class WorkerSample extends Worker { public function do(Message $message) { if ($message->cmd === 'write') { $content = $message->text; echo "$content\n"; } } } try { $client = new Client(); $client->loop('test_queue', new WorkerSample()); } catch (Exception $e) { echo $e->getMessage(); }
Queue
<?php require_once __DIR__ . '/vendor/autoload.php'; use RedisQueue\Client; try { $client = new Client(); $data = [ 'cmd' => 'write', 'text' => 'Hello world!', ]; $client->push('test_queue', $data); echo "RPUSH " . json_encode($data) . " .\n"; } catch (Exception $e) { echo $e->getMessage(); }