1 | <?php |
||
13 | class PredisSetDriver implements DriverInterface |
||
14 | { |
||
15 | use MaxItemsTrait; |
||
16 | use ShutdownTrait; |
||
17 | use SerializerAwareTrait; |
||
18 | |||
19 | private $queues = []; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $scheduleKey; |
||
25 | |||
26 | /** |
||
27 | * @var Client |
||
28 | */ |
||
29 | private $redis; |
||
30 | |||
31 | /** |
||
32 | * @var integer |
||
33 | */ |
||
34 | private $refreshInterval; |
||
35 | |||
36 | /** |
||
37 | * Create new PredisSetDriver |
||
38 | * |
||
39 | * This driver is using redis set. With send message it add new item to set |
||
40 | * and in wait() command it is reading new items in this set. |
||
41 | * This driver doesn't use redis pubsub functionality, only redis sets. |
||
42 | * |
||
43 | * Managing connection to redis is up to you and you have to create it outsite |
||
44 | * of this class. You will need to install predis php package. |
||
45 | * |
||
46 | * @see examples/redis |
||
47 | * |
||
48 | * @param Client $redis |
||
49 | * @param string $key |
||
50 | * @param integer $refreshInterval |
||
51 | * @param string $scheduleKey |
||
52 | */ |
||
53 | public function __construct(Client $redis, string $key = 'hermes', int $refreshInterval = 1, string $scheduleKey = 'hermes_schedule') |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | public function send(MessageInterface $message, int $priority = Dispatcher::PRIORITY_MEDIUM): bool |
||
76 | |||
77 | public function setupPriorityQueue(string $name, int $priority): void |
||
82 | |||
83 | private function getKey(int $priority): string |
||
90 | |||
91 | /**s |
||
92 | * {@inheritdoc} |
||
93 | * |
||
94 | * @throws ShutdownException |
||
95 | */ |
||
96 | public function wait(Closure $callback, array $priorities = []): void |
||
143 | } |
||
144 |