1 | <?php |
||
27 | class SymfonyCache implements CacheAdapterInterface |
||
28 | { |
||
29 | /** |
||
30 | * @var RouterInterface |
||
31 | */ |
||
32 | protected $router; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $cacheDir; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $token; |
||
43 | |||
44 | /** |
||
45 | * @var string[] |
||
46 | */ |
||
47 | protected $types; |
||
48 | |||
49 | /** |
||
50 | * @var bool |
||
51 | */ |
||
52 | protected $phpCodeCacheEnabled; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $servers; |
||
58 | |||
59 | /** |
||
60 | * @var array |
||
61 | */ |
||
62 | protected $timeouts; |
||
63 | |||
64 | /** |
||
65 | * @var Filesystem |
||
66 | */ |
||
67 | protected $filesystem; |
||
68 | |||
69 | /** |
||
70 | * Constructor. |
||
71 | * |
||
72 | * @param RouterInterface $router A router instance |
||
73 | * @param Filesystem $filesystem A Symfony Filesystem component instance |
||
74 | * @param string $cacheDir A Symfony cache directory |
||
75 | * @param string $token A token to clear the related cache |
||
76 | * @param bool $phpCodeCacheEnabled If true, will clear OPcache code cache |
||
77 | * @param array $types A cache types array |
||
78 | * @param array $servers An array of servers |
||
79 | * @param array $timeouts An array of timeout options |
||
80 | */ |
||
81 | public function __construct(RouterInterface $router, Filesystem $filesystem, $cacheDir, $token, $phpCodeCacheEnabled, array $types, array $servers, array $timeouts) |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function flushAll(): bool |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | * |
||
104 | * @throws \InvalidArgumentException |
||
105 | */ |
||
106 | public function flush(array $keys = ['all']): bool |
||
159 | |||
160 | /** |
||
161 | * Symfony cache action. |
||
162 | * |
||
163 | * @param string $token A Sonata symfony cache token |
||
164 | * @param string $type A cache type to invalidate (doctrine, translations, twig, ...) |
||
165 | * |
||
166 | * @return Response |
||
167 | * |
||
168 | * @throws AccessDeniedHttpException if token is invalid |
||
169 | * @throws \RuntimeException if specified type is not in allowed types list |
||
170 | */ |
||
171 | public function cacheAction($token, $type) |
||
199 | |||
200 | /** |
||
201 | * {@inheritdoc} |
||
202 | */ |
||
203 | public function has(array $keys): bool |
||
207 | |||
208 | /** |
||
209 | * {@inheritdoc} |
||
210 | */ |
||
211 | public function set(array $keys, $data, int $ttl = 84600, array $contextualKeys = []): CacheElementInterface |
||
215 | |||
216 | /** |
||
217 | * {@inheritdoc} |
||
218 | */ |
||
219 | public function get(array $keys): CacheElementInterface |
||
223 | |||
224 | /** |
||
225 | * {@inheritdoc} |
||
226 | */ |
||
227 | public function isContextual(): bool |
||
231 | |||
232 | /** |
||
233 | * Returns URL with given token used for cache invalidation. |
||
234 | * |
||
235 | * @param string $type |
||
236 | * |
||
237 | * @return string |
||
238 | */ |
||
239 | protected function getUrl($type) |
||
246 | |||
247 | /** |
||
248 | * Clears code cache with PHP OPcache. |
||
249 | */ |
||
250 | protected function clearPHPCodeCache() |
||
260 | } |
||
261 |