Skip to content

Commit 896f24c

Browse files
committed
Added working example for ChainCache
1 parent d17d83d commit 896f24c

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

cache.rst

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ case the value needs to be recalculated.
389389
cache:
390390
pools:
391391
my_cache_pool:
392-
adapter: app.my_cache_chain_adapter
392+
adapter: cache.adapter.psr6
393+
provider: app.my_cache_chain_adapter
393394
cache.my_redis:
394395
adapter: cache.adapter.redis
395396
provider: 'redis://user:[email protected]'
@@ -418,17 +419,19 @@ case the value needs to be recalculated.
418419
419420
<framework:config>
420421
<framework:cache>
421-
<framework:pool name="my_cache_pool" adapter="app.my_cache_chain_adapter"/>
422+
<framework:pool name="my_cache_pool" adapter="cache.adapter.psr6" provider="app.my_cache_chain_adapter"/>
422423
<framework:pool name="cache.my_redis" adapter="cache.adapter.redis" provider="redis://user:[email protected]"/>
424+
<framework:pool name="cache.apcu" adapter="cache.adapter.apcu"/>
425+
<framework:pool name="cache.array" adapter="cache.adapter.array"/>
423426
</framework:cache>
424427
</framework:config>
425428
426429
<services>
427430
<service id="app.my_cache_chain_adapter" class="Symfony\Component\Cache\Adapter\ChainAdapter">
428431
<argument type="collection">
429-
<argument type="service" value="cache.adapter.array"/>
432+
<argument type="service" value="cache.array"/>
433+
<argument type="service" value="cache.apcu"/>
430434
<argument type="service" value="cache.my_redis"/>
431-
<argument type="service" value="cache.adapter.file"/>
432435
</argument>
433436
<argument>31536000</argument>
434437
</service>
@@ -442,28 +445,37 @@ case the value needs to be recalculated.
442445
'cache' => [
443446
'pools' => [
444447
'my_cache_pool' => [
445-
'adapter' => 'app.my_cache_chain_adapter',
448+
'adapter' => 'cache.adapter.psr6',
449+
'provider' => 'app.my_cache_chain_adapter',
446450
],
447451
'cache.my_redis' => [
448452
'adapter' => 'cache.adapter.redis',
449453
'provider' => 'redis://user:[email protected]',
450454
],
455+
'cache.apcu' => [
456+
'adapter' => 'cache.adapter.apcu',
457+
],
458+
'cache.array' => [
459+
'adapter' => 'cache.adapter.array',
460+
],
451461
],
452462
],
453463
]);
454464
455465
$container->getDefinition('app.my_cache_chain_adapter', \Symfony\Component\Cache\Adapter\ChainAdapter::class)
456466
->addArgument([
457-
new Reference('cache.adapter.array'),
467+
new Reference('cache.array'),
468+
new Reference('cache.apcu'),
458469
new Reference('cache.my_redis'),
459-
new Reference('cache.adapter.file'),
460470
])
461471
->addArgument(31536000);
462472
463473
.. note::
464474

465-
In this configuration there is a ``cache.my_redis`` pool that is used as an
466-
adapter in the ``app.my_cache_chain_adapter``
475+
In this configuration the ``my_cache_pool`` pool is using the ``cache.adapter.psr6``
476+
adapter and the ``app.my_cache_chain_adapter`` service as a provider. That is
477+
because ``ChainAdapter`` does not support the ``cache.pool`` tag. So it is decorated
478+
with the ``ProxyAdapter``.
467479

468480

469481
Using Cache Tags

0 commit comments

Comments
 (0)