1 | <?php |
||
22 | class PhpRedisConnection extends LaravelPhpRedisConnection |
||
23 | { |
||
24 | /** |
||
25 | * The number of times the client attempts to retry a command when it fails |
||
26 | * to connect to a Redis instance behind Sentinel. |
||
27 | * |
||
28 | * @var int |
||
29 | */ |
||
30 | protected $retryLimit = 20; |
||
31 | |||
32 | /** |
||
33 | * The time in milliseconds to wait before the client retries a failed |
||
34 | * command. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $retryWait = 1000; |
||
39 | |||
40 | /** |
||
41 | * Create a new PhpRedis connection. |
||
42 | * |
||
43 | * @param \Redis $client |
||
44 | * @param callable|null $connector |
||
45 | * @param array $sentinelOptions |
||
46 | * @return void |
||
|
|||
47 | */ |
||
48 | public function __construct($client, callable $connector = null, array $sentinelOptions = []) |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} in addition retry on client failure. |
||
58 | * |
||
59 | * @param mixed $cursor |
||
60 | * @param array $options |
||
61 | * @return mixed |
||
62 | */ |
||
63 | public function scan($cursor, $options = []) |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} in addition retry on client failure. |
||
72 | * |
||
73 | * @param string $key |
||
74 | * @param mixed $cursor |
||
75 | * @param array $options |
||
76 | * @return mixed |
||
77 | */ |
||
78 | public function zscan($key, $cursor, $options = []) |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} in addition retry on client failure. |
||
87 | * |
||
88 | * @param string $key |
||
89 | * @param mixed $cursor |
||
90 | * @param array $options |
||
91 | * @return mixed |
||
92 | */ |
||
93 | public function hscan($key, $cursor, $options = []) |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} in addition retry on client failure. |
||
102 | * |
||
103 | * @param string $key |
||
104 | * @param mixed $cursor |
||
105 | * @param array $options |
||
106 | * @return mixed |
||
107 | */ |
||
108 | public function sscan($key, $cursor, $options = []) |
||
114 | |||
115 | /** |
||
116 | * {@inheritdoc} in addition retry on client failure. |
||
117 | * |
||
118 | * @param callable|null $callback |
||
119 | * @return \Redis|array |
||
120 | */ |
||
121 | public function pipeline(callable $callback = null) |
||
127 | |||
128 | /** |
||
129 | * {@inheritdoc} in addition retry on client failure. |
||
130 | * |
||
131 | * @param callable|null $callback |
||
132 | * @return \Redis|array |
||
133 | */ |
||
134 | public function transaction(callable $callback = null) |
||
140 | |||
141 | /** |
||
142 | * {@inheritdoc} in addition retry on client failure. |
||
143 | * |
||
144 | * @param array|string $channels |
||
145 | * @param \Closure $callback |
||
146 | * @return void |
||
147 | */ |
||
148 | public function subscribe($channels, Closure $callback) |
||
154 | |||
155 | /** |
||
156 | * {@inheritdoc} in addition retry on client failure. |
||
157 | * |
||
158 | * @param array|string $channels |
||
159 | * @param \Closure $callback |
||
160 | * @return void |
||
161 | */ |
||
162 | public function psubscribe($channels, Closure $callback) |
||
168 | |||
169 | /** |
||
170 | * {@inheritdoc} in addition retry on client failure. |
||
171 | * |
||
172 | * @param string $method |
||
173 | * @param array $parameters |
||
174 | * @return mixed |
||
175 | */ |
||
176 | public function command($method, array $parameters = []) |
||
182 | |||
183 | /** |
||
184 | * Attempt to retry the provided operation when the client fails to connect |
||
185 | * to a Redis server. |
||
186 | * |
||
187 | * @param callable $callback The operation to execute. |
||
188 | * @return mixed The result of the first successful attempt. |
||
189 | * |
||
190 | * @throws RedisException After exhausting the allowed number of |
||
191 | * attempts to reconnect. |
||
192 | */ |
||
193 | protected function retryOnFailure(callable $callback) |
||
218 | } |
||
219 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.