1 | <?php |
||
5 | trait Streams |
||
6 | { |
||
7 | /** |
||
8 | * Acknowledge one or more pending messages. |
||
9 | * |
||
10 | * @param string $stream |
||
11 | * @param string $group |
||
12 | * @param array $messages |
||
13 | * |
||
14 | * @return int The number of messages Redis reports as acknowledged. |
||
15 | */ |
||
16 | public function xAck(string $stream, string $group, array $messages): int |
||
20 | |||
21 | |||
22 | /** |
||
23 | * Appends the specified stream entry to the stream at the specified key. |
||
24 | * If the key does not exist, as a side effect of running this command the |
||
25 | * key is created with a stream value. |
||
26 | * See: https://redis.io/commands/xadd. |
||
27 | * |
||
28 | * @param string $key |
||
29 | * @param string $id |
||
30 | * @param array $message |
||
31 | * @param int|integer $maxLenght |
||
32 | * @param bool $approximate |
||
33 | * |
||
34 | * @return string The added message ID |
||
35 | */ |
||
36 | public function xAdd( |
||
53 | |||
54 | |||
55 | /** |
||
56 | * Claim ownership of one or more pending messages. |
||
57 | * |
||
58 | * @param string $stream |
||
59 | * @param string $group |
||
60 | * @param string $consumer |
||
61 | * @param int $minIdleTime |
||
62 | * @param array $messageIds |
||
63 | * @param array|null $options |
||
64 | * |
||
65 | * @return array Either an array of message IDs along with |
||
66 | * corresponding data, or just an array of |
||
67 | * IDs (if the 'JUSTID' option was passed). |
||
68 | */ |
||
69 | public function xClaim( |
||
86 | |||
87 | |||
88 | /** |
||
89 | * Delete one or more messages from a stream. |
||
90 | * |
||
91 | * @param string $stream |
||
92 | * @param array $messageIds |
||
93 | * |
||
94 | * @return int The number of messages removed. |
||
95 | */ |
||
96 | public function xDel(string $stream, array $messageIds): int |
||
100 | |||
101 | |||
102 | /** |
||
103 | * This command is used in order to create, destroy, or manage consumer groups. |
||
104 | * |
||
105 | * @param string $command [description] |
||
106 | * @param string|null $stream [description] |
||
107 | * @param string|null $group [description] |
||
108 | * @param [type] $messageId_consumerName [description] |
||
109 | * @param bool|boolean $makeStream [description] |
||
110 | * |
||
111 | * @return mixed This command returns different |
||
112 | * types depending on the specific |
||
113 | * XGROUP command executed. |
||
114 | */ |
||
115 | public function xGroup( |
||
124 | |||
125 | public function xInfo(): bool |
||
129 | |||
130 | public function xLen(): bool |
||
134 | |||
135 | public function xPending(): bool |
||
139 | |||
140 | public function xRange(): bool |
||
144 | |||
145 | public function xRead(): bool |
||
149 | |||
150 | public function xReadGroup(): bool |
||
154 | |||
155 | public function xRevRange(): bool |
||
159 | |||
160 | public function xTrim(): bool |
||
164 | |||
165 | /** |
||
166 | * ************************************************************************ |
||
167 | * H E L P E R F U N C T I O N S |
||
168 | * ************************************************************************ |
||
169 | */ |
||
170 | |||
171 | /** |
||
172 | * Claim Options available |
||
173 | * |
||
174 | * Note: 'TIME', and 'IDLE' are mutually exclusive |
||
175 | * |
||
176 | * 'IDLE' => $value, Set the idle time to $value ms |
||
177 | * 'TIME' => $value, Set the idle time to now - $value |
||
178 | * 'RETRYCOUNT' => $value, Update message retrycount to $value |
||
179 | * 'FORCE', Claim the message(s) even if they're not pending anywhere |
||
180 | * 'JUSTID',Instruct Redis to only return IDs |
||
181 | * |
||
182 | * @param array $options |
||
183 | * |
||
184 | * @return bool |
||
185 | */ |
||
186 | private function _checkClaimOptions(array $options): bool |
||
197 | } |
||
198 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: