1 | <?php |
||
22 | */ |
||
23 | class TagAwareStore extends Store implements ContentPurger |
||
24 | { |
||
25 | const TAG_CACHE_DIR = 'ezcachetag'; |
||
26 | |||
27 | /** |
||
28 | * @var \Symfony\Component\Filesystem\Filesystem |
||
29 | */ |
||
30 | private $fs; |
||
31 | |||
32 | /** |
||
33 | * Injects a Filesystem instance |
||
34 | * For unit tests only. |
||
35 | * |
||
36 | * @internal |
||
37 | * |
||
38 | * @param \Symfony\Component\Filesystem\Filesystem $fs |
||
39 | */ |
||
40 | public function setFilesystem(Filesystem $fs) |
||
44 | |||
45 | /** |
||
46 | * @return \Symfony\Component\Filesystem\Filesystem |
||
47 | */ |
||
48 | public function getFilesystem() |
||
56 | |||
57 | /** |
||
58 | * Writes a cache entry to the store for the given Request and Response. |
||
59 | * |
||
60 | * Existing entries are read and any that match the response are removed. This |
||
61 | * method calls write with the new list of cache entries. |
||
62 | * |
||
63 | * @param Request $request A Request instance |
||
64 | * @param Response $response A Response instance |
||
65 | * |
||
66 | * @return string The key under which the response is stored |
||
67 | * |
||
68 | * @throws \RuntimeException |
||
69 | */ |
||
70 | public function write(Request $request, Response $response) |
||
87 | |||
88 | /** |
||
89 | * Save digest for the given tag. |
||
90 | * |
||
91 | * @internal This is almost verbatim copy of save() from parent class as it is private. |
||
92 | * |
||
93 | * @param string $tag The tag key |
||
94 | * @param string $digest The digest hash to store representing the cache item. |
||
95 | * |
||
96 | * @return bool|void |
||
97 | */ |
||
98 | private function saveTag($tag, $digest) |
||
122 | |||
123 | /** |
||
124 | * Purges data from $request. |
||
125 | * If xkey or X-Location-Id (deprecated) header is present, the store will purge cache for given locationId or group of locationIds. |
||
126 | * If not, regular purge by URI will occur. |
||
127 | * |
||
128 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
129 | * |
||
130 | * @return bool True if purge was successful. False otherwise |
||
131 | */ |
||
132 | public function purgeByRequest(Request $request) |
||
166 | |||
167 | /** |
||
168 | * Purges all cached content. |
||
169 | * |
||
170 | * @deprecated Use cache:clear, with multi tagging theoretically there shouldn't be need to delete all anymore from core. |
||
171 | * |
||
172 | * @return bool |
||
173 | */ |
||
174 | public function purgeAllContent() |
||
179 | |||
180 | /** |
||
181 | * Purges cache for tag. |
||
182 | * |
||
183 | * @param string $tag |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | private function purgeByCacheTag($tag) |
||
211 | |||
212 | /** |
||
213 | * Returns cache dir for $tag. |
||
214 | * |
||
215 | * This method is public only for unit tests. |
||
216 | * Use it only if you know what you are doing. |
||
217 | * |
||
218 | * @internal |
||
219 | * |
||
220 | * @param int $tag |
||
221 | * |
||
222 | * @return string |
||
223 | */ |
||
224 | public function getCacheTagDir($tag = null) |
||
233 | } |
||
234 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.