1 | <?php |
||
28 | class MultiplexerClient implements BanCapable, PurgeCapable, RefreshCapable, TagCapable, ClearCapable |
||
29 | { |
||
30 | /** |
||
31 | * @var ProxyClient[] |
||
32 | */ |
||
33 | private $proxyClients; |
||
34 | |||
35 | /** |
||
36 | * MultiplexerClient constructor. |
||
37 | * |
||
38 | * @param ProxyClient[] $proxyClients The list of Proxy clients |
||
39 | 8 | */ |
|
40 | public function __construct(array $proxyClients) |
||
53 | |||
54 | /** |
||
55 | * Forwards to all clients. |
||
56 | * |
||
57 | * @param array $headers HTTP headers that path must match to be banned |
||
58 | * |
||
59 | * @return $this |
||
60 | 1 | */ |
|
61 | public function ban(array $headers) |
||
67 | |||
68 | /** |
||
69 | * Forwards to all clients. |
||
70 | * |
||
71 | * @param string $path Regular expression pattern for URI to invalidate |
||
72 | * @param string $contentType Regular expression pattern for the content type to limit banning, for instance |
||
73 | * 'text' |
||
74 | * @param array|string $hosts Regular expression of a host name or list of exact host names to limit banning |
||
75 | * |
||
76 | * @return $this |
||
77 | 1 | */ |
|
78 | public function banPath($path, $contentType = null, $hosts = null) |
||
84 | |||
85 | /** |
||
86 | * Forwards to all clients. |
||
87 | * |
||
88 | * @throws ExceptionCollection If any errors occurred during flush |
||
89 | * |
||
90 | * @return int The number of cache invalidations performed per caching server |
||
91 | 1 | */ |
|
92 | public function flush() |
||
101 | |||
102 | /** |
||
103 | * Forwards tag invalidation request to all clients. |
||
104 | * |
||
105 | * {@inheritdoc} |
||
106 | * |
||
107 | * @param array $tags |
||
108 | * |
||
109 | * @return $this |
||
110 | 1 | */ |
|
111 | public function invalidateTags(array $tags) |
||
117 | |||
118 | /** |
||
119 | * Forwards to all clients. |
||
120 | * |
||
121 | * @param string $url Path or URL to purge |
||
122 | * @param array $headers Extra HTTP headers to send to the caching proxy (optional) |
||
123 | * |
||
124 | * @return $this |
||
125 | 1 | */ |
|
126 | public function purge($url, array $headers = []) |
||
132 | |||
133 | /** |
||
134 | * Forwards to all clients. |
||
135 | * |
||
136 | * @param string $url Path or URL to refresh |
||
137 | * @param array $headers Extra HTTP headers to send to the caching proxy (optional) |
||
138 | * |
||
139 | * @return $this |
||
140 | 1 | */ |
|
141 | public function refresh($url, array $headers = []) |
||
147 | |||
148 | /** |
||
149 | * Forwards to all clients. |
||
150 | * |
||
151 | * @return $this |
||
152 | */ |
||
153 | public function clear() |
||
159 | |||
160 | 5 | /** |
|
161 | * Invoke the given $method on all available ProxyClients implementing the |
||
162 | * given $interface. |
||
163 | * |
||
164 | * @param string $interface The FQN of the interface |
||
165 | * @param string $method The method to invoke |
||
166 | * @param array $arguments The arguments to be passed to the method |
||
167 | */ |
||
168 | private function invoke($interface, $method, array $arguments) |
||
174 | |||
175 | /** |
||
176 | * Invoke the given $method on the first available ProxyClient implementing |
||
177 | * the given $interface. |
||
178 | * |
||
179 | * @param string $interface The FQN of the interface |
||
180 | * @param string $method The method to invoke |
||
181 | * @param array $arguments The arguments to be passed to the method |
||
182 | * |
||
183 | * @return mixed Return value of ProxyClient method call |
||
184 | * |
||
185 | * @throws UnsupportedProxyOperationException |
||
186 | */ |
||
187 | private function invokeFirst($interface, $method, array $arguments) |
||
195 | 5 | ||
196 | 5 | /** |
|
197 | * Get proxy clients that implement a feature interface. |
||
198 | * |
||
199 | * @param string $interface |
||
200 | * |
||
201 | * @return ProxyClient[] |
||
202 | */ |
||
203 | private function getProxyClients($interface) |
||
212 | } |
||
213 |