Skip to content

Commit 49a29de

Browse files
committed
minor #11813 [Cache] Make sure the chain cache configuration works (Nyholm)
This PR was submitted for the 4.3 branch but it was squashed and merged into the 3.4 branch instead (closes #11813). Discussion ---------- [Cache] Make sure the chain cache configuration works I just tried the configuration and noticed a few issues. ~~Im not 100% sure this actually works.~~ Lets wait for symfony/symfony#32139 Im sure now Commits ------- 9fbebaf [Cache] Make sure the chain cache configuration works
2 parents f21c0eb + 9fbebaf commit 49a29de

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

cache.rst

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,22 @@ case the value needs to be recalculated.
413413
cache:
414414
pools:
415415
my_cache_pool:
416-
adapter: app.my_cache_chain_adapter
416+
adapter: cache.adapter.psr6
417+
provider: app.my_cache_chain_adapter
417418
cache.my_redis:
418419
adapter: cache.adapter.redis
419420
provider: 'redis://user:[email protected]'
421+
cache.apcu:
422+
adapter: cache.adapter.apcu
423+
cache.array:
424+
adapter: cache.adapter.array
425+
420426
421427
services:
422428
app.my_cache_chain_adapter:
423429
class: Symfony\Component\Cache\Adapter\ChainAdapter
424430
arguments:
425-
- ['cache.adapter.array', 'cache.my_redis', 'cache.adapter.file']
431+
- ['@cache.array', '@cache.apcu', '@cache.my_redis']
426432
- 31536000 # One year
427433
428434
.. code-block:: xml
@@ -436,18 +442,20 @@ case the value needs to be recalculated.
436442
https://symfony.com/schema/dic/services/services-1.0.xsd">
437443
438444
<framework:config>
439-
<framework:cache default_memcached_provider="memcached://localhost">
440-
<framework:pool name="my_cache_pool" adapter="app.my_cache_chain_adapter"/>
445+
<framework:cache>
446+
<framework:pool name="my_cache_pool" adapter="cache.adapter.psr6" provider="app.my_cache_chain_adapter"/>
441447
<framework:pool name="cache.my_redis" adapter="cache.adapter.redis" provider="redis://user:[email protected]"/>
448+
<framework:pool name="cache.apcu" adapter="cache.adapter.apcu"/>
449+
<framework:pool name="cache.array" adapter="cache.adapter.array"/>
442450
</framework:cache>
443451
</framework:config>
444452
445453
<services>
446454
<service id="app.my_cache_chain_adapter" class="Symfony\Component\Cache\Adapter\ChainAdapter">
447455
<argument type="collection">
448-
<argument type="service" value="cache.adapter.array"/>
456+
<argument type="service" value="cache.array"/>
457+
<argument type="service" value="cache.apcu"/>
449458
<argument type="service" value="cache.my_redis"/>
450-
<argument type="service" value="cache.adapter.file"/>
451459
</argument>
452460
<argument>31536000</argument>
453461
</service>
@@ -461,28 +469,37 @@ case the value needs to be recalculated.
461469
'cache' => [
462470
'pools' => [
463471
'my_cache_pool' => [
464-
'adapter' => 'app.my_cache_chain_adapter',
472+
'adapter' => 'cache.adapter.psr6',
473+
'provider' => 'app.my_cache_chain_adapter',
465474
],
466475
'cache.my_redis' => [
467476
'adapter' => 'cache.adapter.redis',
468477
'provider' => 'redis://user:[email protected]',
469478
],
479+
'cache.apcu' => [
480+
'adapter' => 'cache.adapter.apcu',
481+
],
482+
'cache.array' => [
483+
'adapter' => 'cache.adapter.array',
484+
],
470485
],
471486
],
472487
]);
473488
474489
$container->getDefinition('app.my_cache_chain_adapter', \Symfony\Component\Cache\Adapter\ChainAdapter::class)
475490
->addArgument([
476-
new Reference('cache.adapter.array'),
491+
new Reference('cache.array'),
492+
new Reference('cache.apcu'),
477493
new Reference('cache.my_redis'),
478-
new Reference('cache.adapter.file'),
479494
])
480495
->addArgument(31536000);
481496
482497
.. note::
483498

484-
In this configuration there is a ``cache.my_redis`` pool that is used as an
485-
adapter in the ``app.my_cache_chain_adapter``
499+
In this configuration the ``my_cache_pool`` pool is using the ``cache.adapter.psr6``
500+
adapter and the ``app.my_cache_chain_adapter`` service as a provider. That is
501+
because ``ChainAdapter`` does not support the ``cache.pool`` tag. So it is decorated
502+
with the ``ProxyAdapter``.
486503

487504

488505
Clearing the Cache

0 commit comments

Comments
 (0)