|
14 | 14 | use Psr\Cache\InvalidArgumentException; |
15 | 15 | use Symfony\Component\Cache\Adapter\AdapterInterface; |
16 | 16 | use Symfony\Component\Cache\Adapter\FilesystemAdapter; |
| 17 | +use Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter; |
17 | 18 | use Symfony\Component\Cache\Adapter\TagAwareAdapter; |
18 | 19 | use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; |
19 | 20 | use Symfony\Component\Cache\PruneableInterface; |
@@ -72,7 +73,11 @@ class Psr6Store implements Psr6StoreInterface |
72 | 73 | * adapter and lock factory. |
73 | 74 | * |
74 | 75 | * - cache: Explicitly specify the cache adapter you want to |
75 | | - * use. Make sure that lock and cache have the same |
| 76 | + * use. Note that if you want to make use of cache |
| 77 | + * tagging, this cache must implement the |
| 78 | + * Symfony\Component\Cache\Adapter\TagAwareAdapterInterface |
| 79 | + * |
| 80 | + * Make sure that lock and cache have the same |
76 | 81 | * scope. *Read the warning in the README!* |
77 | 82 | * |
78 | 83 | * Type: Symfony\Component\Cache\Adapter\AdapterInterface |
@@ -118,8 +123,13 @@ public function __construct(array $options = []) |
118 | 123 | throw new MissingOptionsException('The cache_directory option is required unless you set the cache explicitly'); |
119 | 124 | } |
120 | 125 |
|
| 126 | + // As of Symfony 4.3+ we can use the optimized FilesystemTagAwareAdapter |
| 127 | + if (class_exists(FilesystemTagAwareAdapter::class)) { |
| 128 | + return new FilesystemTagAwareAdapter('', 0, $options['cache_directory']); |
| 129 | + } |
| 130 | + |
121 | 131 | return new TagAwareAdapter( |
122 | | - new FilesystemAdapter('http_cache', 0, $options['cache_directory']) |
| 132 | + new FilesystemAdapter('', 0, $options['cache_directory']) |
123 | 133 | ); |
124 | 134 | })->setAllowedTypes('cache', AdapterInterface::class); |
125 | 135 |
|
|
0 commit comments