1 | <?php |
||
26 | class MultiplexerClient implements BanCapable, PurgeCapable, RefreshCapable, TagCapable |
||
27 | { |
||
28 | /** |
||
29 | * @var ProxyClient[] |
||
30 | */ |
||
31 | private $proxyClients; |
||
32 | |||
33 | /** |
||
34 | * MultiplexerClient constructor. |
||
35 | * |
||
36 | * @param ProxyClient[] $proxyClients The list of Proxy clients |
||
37 | */ |
||
38 | 7 | public function __construct(array $proxyClients) |
|
51 | |||
52 | /** |
||
53 | * Forwards to all clients. |
||
54 | * |
||
55 | * @param array $headers HTTP headers that path must match to be banned |
||
56 | * |
||
57 | * @return $this |
||
58 | */ |
||
59 | 1 | public function ban(array $headers) |
|
65 | |||
66 | /** |
||
67 | * Forwards to all clients. |
||
68 | * |
||
69 | * @param string $path Regular expression pattern for URI to invalidate |
||
70 | * @param string $contentType Regular expression pattern for the content type to limit banning, for instance |
||
71 | * 'text' |
||
72 | * @param array|string $hosts Regular expression of a host name or list of exact host names to limit banning |
||
73 | * |
||
74 | * @return $this |
||
75 | */ |
||
76 | 1 | public function banPath($path, $contentType = null, $hosts = null) |
|
82 | |||
83 | /** |
||
84 | * Forwards to all clients. |
||
85 | * |
||
86 | * @throws ExceptionCollection If any errors occurred during flush |
||
87 | * |
||
88 | * @return int The number of cache invalidations performed per caching server |
||
89 | */ |
||
90 | 1 | public function flush() |
|
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | public function getTagsHeaderValue(array $tags) |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | public function getTagsHeaderName() |
||
115 | |||
116 | /** |
||
117 | * Forwards tag invalidation request to all clients. |
||
118 | * |
||
119 | * {@inheritdoc} |
||
120 | * |
||
121 | * @param array $tags |
||
122 | * |
||
123 | * @return $this |
||
124 | */ |
||
125 | public function invalidateTags(array $tags) |
||
131 | |||
132 | /** |
||
133 | * Forwards to all clients. |
||
134 | * |
||
135 | * @param string $url Path or URL to purge |
||
136 | * @param array $headers Extra HTTP headers to send to the caching proxy (optional) |
||
137 | * |
||
138 | * @return $this |
||
139 | */ |
||
140 | 1 | public function purge($url, array $headers = array()) |
|
146 | |||
147 | /** |
||
148 | * Forwards to all clients. |
||
149 | * |
||
150 | * @param string $url Path or URL to refresh |
||
151 | * @param array $headers Extra HTTP headers to send to the caching proxy (optional) |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | 1 | public function refresh($url, array $headers = []) |
|
161 | |||
162 | /** |
||
163 | * Helper function to invoke the given $method on all available ProxyClients implementing the given $interface. |
||
164 | * |
||
165 | * @param string $interface The FQN of the interface |
||
166 | * @param string $method The method to invoke |
||
167 | * @param array $arguments The arguments to be passed to the method |
||
168 | */ |
||
169 | 4 | private function invoke($interface, $method, array $arguments) |
|
177 | } |
||
178 |