1 | <?php |
||
5 | trait InvalidateVarnishCache |
||
6 | { |
||
7 | /** |
||
8 | * Flush entire cache for an application hostname. |
||
9 | * |
||
10 | * @param string $hostname [description] |
||
11 | * @return void |
||
12 | */ |
||
13 | public function flush($hostname) |
||
19 | |||
20 | /** |
||
21 | * Generate ban request for an application hostname, |
||
22 | * specified by a set of regular expression. |
||
23 | * |
||
24 | * @param string $hostname |
||
25 | * @param string|array $patterns |
||
26 | * @return void |
||
27 | */ |
||
28 | public function banByPatterns($hostname, $patterns) |
||
41 | |||
42 | /** |
||
43 | * Generate ban request for an application hostname, |
||
44 | * specified by a set of urls. |
||
45 | * |
||
46 | * @param string $hostname |
||
47 | * @param string|array $urls |
||
48 | * @return void |
||
49 | */ |
||
50 | public function banByUrls($hostname, $urls) |
||
63 | |||
64 | /** |
||
65 | * Get a valid varnish host url to send the |
||
66 | * ban request. |
||
67 | * |
||
68 | * @param string $varnishHost |
||
69 | * @return string |
||
70 | */ |
||
71 | protected function getVarnishUrl($varnishHost) |
||
75 | |||
76 | /** |
||
77 | * Send the ban request to every varnish hosts. |
||
78 | * |
||
79 | * @param array $headers |
||
80 | * @param string $method |
||
81 | * @return void |
||
82 | */ |
||
83 | protected function sendBanRequest(array $headers, $method = 'BAN') |
||
93 | |||
94 | /** |
||
95 | * Get configuration value for a specific key. |
||
96 | * |
||
97 | * @param string $key |
||
98 | * @return mixed |
||
99 | */ |
||
100 | abstract public function getConfig($key); |
||
101 | |||
102 | /** |
||
103 | * Get guzzle client object. |
||
104 | * |
||
105 | * @return \GuzzleHttp\Client |
||
106 | */ |
||
107 | abstract public function getGuzzle(); |
||
108 | } |
||
109 |