1 | <?php |
||
9 | trait InvalidateVarnishCache |
||
10 | { |
||
11 | /** |
||
12 | * Flush entire cache for an application hostname. |
||
13 | * |
||
14 | * @param string $hostname |
||
15 | * |
||
16 | * @return void |
||
17 | * |
||
18 | * @throws GuzzleException |
||
19 | * @throws InvalidArgumentException |
||
20 | */ |
||
21 | public function flush(string $hostname) :void |
||
27 | |||
28 | /** |
||
29 | * Generate ban request for an application hostname, |
||
30 | * specified by a regular expression. |
||
31 | * |
||
32 | * @param string $hostname |
||
33 | * @param string $pattern |
||
34 | * |
||
35 | * @return void |
||
36 | * |
||
37 | * @throws GuzzleException |
||
38 | * @throws InvalidArgumentException |
||
39 | */ |
||
40 | public function banByPattern(string $hostname, string $pattern) :void |
||
47 | |||
48 | /** |
||
49 | * Generate ban request for an application hostname, |
||
50 | * specified by a set of regular expression. |
||
51 | * |
||
52 | * @param string $hostname |
||
53 | * @param array $patterns |
||
54 | * |
||
55 | * @return void |
||
56 | * |
||
57 | * @throws GuzzleException |
||
58 | * @throws InvalidArgumentException |
||
59 | */ |
||
60 | public function banByPatterns(string $hostname, array $patterns) :void |
||
66 | |||
67 | /** |
||
68 | * Generate ban request for an application hostname, |
||
69 | * specified by a single urls. |
||
70 | * |
||
71 | * @param string $hostname |
||
72 | * @param string $url |
||
73 | * |
||
74 | * @return void |
||
75 | * |
||
76 | * @throws GuzzleException |
||
77 | * @throws InvalidArgumentException |
||
78 | */ |
||
79 | public function banByUrl(string $hostname, string $url) :void |
||
86 | |||
87 | /** |
||
88 | * Generate ban request for an application hostname, |
||
89 | * specified by a set of urls. |
||
90 | * |
||
91 | * @param string $hostname |
||
92 | * @param array $urls |
||
93 | * |
||
94 | * @return void |
||
95 | * |
||
96 | * @throws GuzzleException |
||
97 | * @throws InvalidArgumentException |
||
98 | */ |
||
99 | public function banByUrls(string $hostname, array $urls) :void |
||
105 | |||
106 | /** |
||
107 | * Get a valid varnish host url to send the |
||
108 | * ban request. |
||
109 | * |
||
110 | * @param string $varnishHost |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | protected function getVarnishUrl(string $varnishHost) :string |
||
118 | |||
119 | /** |
||
120 | * Send the ban request to every varnish hosts. |
||
121 | * |
||
122 | * @param array $headers |
||
123 | * @param string $method |
||
124 | * |
||
125 | * @return void |
||
126 | * |
||
127 | * @throws GuzzleException |
||
128 | * @throws InvalidArgumentException |
||
129 | */ |
||
130 | protected function sendBanRequest(array $headers, string $method = 'BAN') :void |
||
140 | |||
141 | /** |
||
142 | * Get configuration value for a specific key. |
||
143 | * |
||
144 | * @param string $key |
||
145 | * |
||
146 | * @return mixed |
||
147 | */ |
||
148 | abstract public function getConfig($key); |
||
149 | |||
150 | /** |
||
151 | * Get guzzle client object. |
||
152 | * |
||
153 | * @return \GuzzleHttp\Client |
||
154 | */ |
||
155 | abstract public function getGuzzle() :Client; |
||
156 | } |
||
157 |