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