1 | <?php |
||
11 | class RedisSetDriver implements DriverInterface |
||
12 | { |
||
13 | use MaxItemsTrait; |
||
14 | use SerializerAwareTrait; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $key; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $scheduleKey; |
||
25 | |||
26 | /** |
||
27 | * @var Redis|Predis\Client |
||
28 | */ |
||
29 | private $redis; |
||
30 | |||
31 | /** |
||
32 | * @var integer |
||
33 | */ |
||
34 | private $refreshInterval; |
||
35 | |||
36 | /** |
||
37 | * Create new RedisSetDriver |
||
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 can use native Redis php extension or Predis extension. |
||
45 | * |
||
46 | * @see examples/redis |
||
47 | 21 | * |
|
48 | * @param Redis\Predis\Client $redis |
||
49 | 21 | * @param string $key |
|
50 | 3 | * @param integer $refreshInterval |
|
51 | * @param string $scheduleKey |
||
52 | */ |
||
53 | 18 | public function __construct($redis, string $key = 'hermes', int $refreshInterval = 1, string $scheduleKey = 'hermes_schedule') |
|
65 | 6 | ||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function send(MessageInterface $message): bool |
||
78 | |||
79 | 6 | /** |
|
80 | 3 | * {@inheritdoc} |
|
81 | 2 | */ |
|
82 | 6 | public function wait(Closure $callback): void |
|
133 | } |
||
134 |