Skip to content

Commit b914ab6

Browse files
committed
Merge branch 'release/2.0.0'
2 parents d1c761c + f4333d8 commit b914ab6

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ that…
1919
* …instead of re-implementing locking and caching mechanisms again, uses the well
2020
tested Symfony Cache and Lock components, both with the local filesystem adapters
2121
by default.
22-
* …thanks to the `TagAwareAdapter` of the Cache component, supports tag based cache
23-
invalidation.
22+
* …thanks to the `TagAwareAdapterInterface` of the Cache component, supports tag
23+
based cache invalidation.
2424
* …thanks to the `PrunableInterface` of the Cache component, supports auto-pruning
2525
of expired entries on the filesystem trying to prevent flooding the filesystem.
26-
* …allows you to use a different PSR-6 cache adapters as well as a differenent
26+
* …allows you to use a different PSR-6 cache adapters as well as a different
2727
lock adapter than the local filesystem ones.
2828
However, **be careful about choosing the right adapters**, see warning below.
2929

@@ -86,8 +86,11 @@ passing an array of `$options` in the constructor:
8686

8787
**Type**: `string`
8888

89-
* **cache**: Explicitly specify the cache adapter you want to use. Make sure
90-
that `lock` and `cache` have the same scope. *See warning below!*
89+
* **cache**: Explicitly specify the cache adapter you want to use.
90+
91+
Note that if you want to make use of cache tagging, this cache must
92+
implement the `Symfony\Component\Cache\Adapter\TagAwareAdapterInterface`
93+
Make sure that `lock` and `cache` have the same scope. *See warning below!*
9194

9295
**Type**: `Symfony\Component\Cache\Adapter\AdapterInterface`
9396
**Default**: `FilesystemAdapter` instance with `cache_directory`

src/Psr6Store.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Psr\Cache\InvalidArgumentException;
1515
use Symfony\Component\Cache\Adapter\AdapterInterface;
1616
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
17+
use Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter;
1718
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
1819
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
1920
use Symfony\Component\Cache\PruneableInterface;
@@ -72,7 +73,11 @@ class Psr6Store implements Psr6StoreInterface
7273
* adapter and lock factory.
7374
*
7475
* - 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
7681
* scope. *Read the warning in the README!*
7782
*
7883
* Type: Symfony\Component\Cache\Adapter\AdapterInterface
@@ -118,8 +123,13 @@ public function __construct(array $options = [])
118123
throw new MissingOptionsException('The cache_directory option is required unless you set the cache explicitly');
119124
}
120125

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+
121131
return new TagAwareAdapter(
122-
new FilesystemAdapter('http_cache', 0, $options['cache_directory'])
132+
new FilesystemAdapter('', 0, $options['cache_directory'])
123133
);
124134
})->setAllowedTypes('cache', AdapterInterface::class);
125135

0 commit comments

Comments
 (0)