@@ -230,7 +230,7 @@ You can also create more customized pools:
230
230
<framework : pool name =" my_cache_pool" adapter =" cache.adapter.array" />
231
231
<framework : pool name =" acme.cache" adapter =" cache.adapter.memcached" />
232
232
<framework : pool name =" foobar.cache" adapter =" cache.adapter.memcached" provider =" memcached://user:[email protected] " />
233
- <framework : pool name =" short_cache" adapter =" foobar.cache" default_lifetime =" 60" />
233
+ <framework : pool name =" short_cache" adapter =" foobar.cache" default-lifetime =" 60" />
234
234
</framework : cache >
235
235
</framework : config >
236
236
</container >
@@ -376,6 +376,10 @@ To get the best of both worlds you may use a chain of adapters. The idea is to
376
376
first look at the quick adapter and then move on to slower adapters. In the worst
377
377
case the value needs to be recalculated.
378
378
379
+ .. versionadded :: 4.4
380
+
381
+ Support for configure a chain using ``framework.cache.pools `` was introduced in Symfony 4.4.
382
+
379
383
.. configuration-block ::
380
384
381
385
.. code-block :: yaml
@@ -385,23 +389,15 @@ case the value needs to be recalculated.
385
389
cache :
386
390
pools :
387
391
my_cache_pool :
388
- adapter : cache.adapter.psr6
389
- provider : app.my_cache_chain_adapter
392
+ default_lifetime : 31536000 # One year
393
+ adapters :
394
+ - cache.adapter.array
395
+ - cache.adapter.apcu
396
+ - cache.my_redis
397
+
390
398
cache.my_redis :
391
399
adapter : cache.adapter.redis
392
400
provider : ' redis://user:[email protected] '
393
- cache.apcu :
394
- adapter : cache.adapter.apcu
395
- cache.array :
396
- adapter : cache.adapter.array
397
-
398
-
399
- services :
400
- app.my_cache_chain_adapter :
401
- class : Symfony\Component\Cache\Adapter\ChainAdapter
402
- arguments :
403
- - ['@cache.array', '@cache.apcu', '@cache.my_redis']
404
- - 31536000 # One year
405
401
406
402
.. code-block :: xml
407
403
@@ -415,23 +411,13 @@ case the value needs to be recalculated.
415
411
416
412
<framework : config >
417
413
<framework : cache >
418
- <framework : pool name =" my_cache_pool" adapter =" cache.adapter.psr6" provider =" app.my_cache_chain_adapter" />
419
- <framework : pool name =" cache.my_redis" adapter =" cache.adapter.redis" provider =" redis://user:[email protected] " />
420
- <framework : pool name =" cache.apcu" adapter =" cache.adapter.apcu" />
421
- <framework : pool name =" cache.array" adapter =" cache.adapter.array" />
414
+ <framework : pool name =" my_cache_pool" default-lifetime =" 31536000" >
415
+ <framework : adapter name =" cache.adapter.array" />
416
+ <framework : adapter name =" cache.adapter.apcu" />
417
+ <framework : adapter name =" cache.adapter.redis" provider =" app.cache.provider.redis" />
418
+ </framework : pool >
422
419
</framework : cache >
423
420
</framework : config >
424
-
425
- <services >
426
- <service id =" app.my_cache_chain_adapter" class =" Symfony\Component\Cache\Adapter\ChainAdapter" >
427
- <argument type =" collection" >
428
- <argument type =" service" value =" cache.array" />
429
- <argument type =" service" value =" cache.apcu" />
430
- <argument type =" service" value =" cache.my_redis" />
431
- </argument >
432
- <argument >31536000</argument >
433
- </service >
434
- </services >
435
421
</container >
436
422
437
423
.. code-block :: php
@@ -441,31 +427,21 @@ case the value needs to be recalculated.
441
427
'cache' => [
442
428
'pools' => [
443
429
'my_cache_pool' => [
444
- 'adapter' => 'cache.adapter.psr6',
445
- 'provider' => 'app.my_cache_chain_adapter',
430
+ 'default_lifetime' => 31536000, // One year
431
+ 'adapters' => [
432
+ 'cache.adapter.array',
433
+ 'cache.adapter.apcu',
434
+ 'cache.my_redis',
435
+ ],
446
436
],
447
437
'cache.my_redis' => [
448
438
'adapter' => 'cache.adapter.redis',
449
439
'provider' => 'redis://user:[email protected] ',
450
440
],
451
- 'cache.apcu' => [
452
- 'adapter' => 'cache.adapter.apcu',
453
- ],
454
- 'cache.array' => [
455
- 'adapter' => 'cache.adapter.array',
456
- ],
457
441
],
458
442
],
459
443
]);
460
444
461
- $container->getDefinition('app.my_cache_chain_adapter', \Symfony\Component\Cache\Adapter\ChainAdapter::class)
462
- ->addArgument([
463
- new Reference('cache.array'),
464
- new Reference('cache.apcu'),
465
- new Reference('cache.my_redis'),
466
- ])
467
- ->addArgument(31536000);
468
-
469
445
.. note ::
470
446
471
447
In this configuration the ``my_cache_pool `` pool is using the ``cache.adapter.psr6 ``
0 commit comments