@@ -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 configuring 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,11 @@ 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
390
- cache.my_redis :
391
- adapter : cache.adapter.redis
392
- 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
392
+ default_lifetime : 31536000 # One year
393
+ adapters :
394
+ - cache.adapter.array
395
+ - cache.adapter.apcu
396
+ - {name: cache.adapter.redis, provider: 'redis://user:[email protected] '}
405
397
406
398
.. code-block :: xml
407
399
@@ -415,23 +407,13 @@ case the value needs to be recalculated.
415
407
416
408
<framework : config >
417
409
<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" />
410
+ <framework : pool name =" my_cache_pool" default-lifetime =" 31536000" >
411
+ <framework : adapter name =" cache.adapter.array" />
412
+ <framework : adapter name =" cache.adapter.apcu" />
413
+ <framework : adapter name =" cache.adapter.redis" provider =" redis://user:[email protected] " />
414
+ </framework : pool >
422
415
</framework : cache >
423
416
</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
417
</container >
436
418
437
419
.. code-block :: php
@@ -441,39 +423,17 @@ case the value needs to be recalculated.
441
423
'cache' => [
442
424
'pools' => [
443
425
'my_cache_pool' => [
444
- 'adapter' => 'cache.adapter.psr6',
445
- 'provider' => 'app.my_cache_chain_adapter',
446
- ],
447
- 'cache.my_redis' => [
448
- 'adapter' => 'cache.adapter.redis',
449
- 'provider' => 'redis://user:[email protected] ',
450
- ],
451
- 'cache.apcu' => [
452
- 'adapter' => 'cache.adapter.apcu',
453
- ],
454
- 'cache.array' => [
455
- 'adapter' => 'cache.adapter.array',
426
+ 'default_lifetime' => 31536000, // One year
427
+ 'adapters' => [
428
+ 'cache.adapter.array',
429
+ 'cache.adapter.apcu',
430
+ ['name' => 'cache.adapter.redis', 'provider' => 'redis://user:[email protected] '],
431
+ ],
456
432
],
457
433
],
458
434
],
459
435
]);
460
436
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
- .. note ::
470
-
471
- In this configuration the ``my_cache_pool `` pool is using the ``cache.adapter.psr6 ``
472
- adapter and the ``app.my_cache_chain_adapter `` service as a provider. That is
473
- because ``ChainAdapter `` does not support the ``cache.pool `` tag. So it is decorated
474
- with the ``ProxyAdapter ``.
475
-
476
-
477
437
Using Cache Tags
478
438
----------------
479
439
0 commit comments