@@ -85,12 +85,15 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
8585 ..code-block ::php
8686
8787 // config/packages/cache.php
88- $container->loadFromExtension('framework', [
89- 'cache' => [
90- 'app' => 'cache.adapter.filesystem',
91- 'system' => 'cache.adapter.system',
92- ],
93- ]);
88+ use Symfony\Config\FrameworkConfig;
89+
90+ return static function (FrameworkConfig $framework) {
91+ $framework->cache()
92+ ->app('cache.adapter.filesystem')
93+ ->system('cache.adapter.system')
94+ ;
95+ };
96+
9497
9598 The Cache component comes with a series of adapters pre-configured:
9699
@@ -165,23 +168,24 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
165168 ..code-block ::php
166169
167170 // config/packages/cache.php
168- $container->loadFromExtension('framework', [
169- 'cache' => [
170- // Only used with cache.adapter.filesystem
171- 'directory' => '%kernel.cache_dir%/pools',
171+ use Symfony\Config\FrameworkConfig;
172172
173+ return static function (FrameworkConfig $framework) {
174+ $framework->cache()
175+ // Only used with cache.adapter.filesystem
176+ ->directory('%kernel.cache_dir%/pools')
173177 // Service: cache.doctrine
174- 'default_doctrine_provider' => 'app.doctrine_cache',
178+ ->defaultDoctrineProvider( 'app.doctrine_cache')
175179 // Service: cache.psr6
176- 'default_psr6_provider' => 'app.my_psr6_service',
180+ ->defaultPsr6Provider( 'app.my_psr6_service')
177181 // Service: cache.redis
178- 'default_redis_provider' => 'redis://localhost',
182+ ->defaultRedisProvider( 'redis://localhost')
179183 // Service: cache.memcached
180- 'default_memcached_provider' => 'memcached://localhost',
184+ ->defaultMemcachedProvider( 'memcached://localhost')
181185 // Service: cache.pdo
182- 'default_pdo_provider' => 'doctrine.dbal.default_connection',
183- ],
184- ]) ;
186+ ->defaultPdoProvider( 'doctrine.dbal.default_connection')
187+ ;
188+ } ;
185189
186190 .. _cache-create-pools :
187191
@@ -267,43 +271,36 @@ You can also create more customized pools:
267271 ..code-block ::php
268272
269273 // config/packages/cache.php
270- $container->loadFromExtension('framework', [
271- 'cache' => [
272- 'default_memcached_provider' => 'memcached://localhost',
273- 'pools' => [
274- // creates a "custom_thing.cache" service
275- // autowireable via "CacheInterface $customThingCache"
276- // uses the "app" cache configuration
277- 'custom_thing.cache' => [
278- 'adapter' => 'cache.app',
279- ],
280-
281- // creates a "my_cache_pool" service
282- // autowireable via "CacheInterface $myCachePool"
283- 'my_cache_pool' => [
284- 'adapter' => 'cache.adapter.filesystem',
285- ],
286-
287- // uses the default_memcached_provider from above
288- 'acme.cache' => [
289- 'adapter' => 'cache.adapter.memcached',
290- ],
291-
292- // control adapter's configuration
293- 'foobar.cache' => [
294- 'adapter' => 'cache.adapter.memcached',
295- 'provider' => 'memcached://user:password@example.com',
296- ],
297-
298- // uses the "foobar.cache" pool as its backend but controls
299- // the lifetime and (like all pools) has a separate cache namespace
300- 'short_cache' => [
301- 'adapter' => 'foobar.cache',
302- 'default_lifetime' => 60,
303- ],
304- ],
305- ],
306- ]);
274+ use Symfony\Config\FrameworkConfig;
275+
276+ return static function (FrameworkConfig $framework) {
277+ $cache = $framework->cache();
278+ $cache->defaultMemcachedProvider('memcached://localhost');
279+
280+ // creates a "custom_thing.cache" service
281+ // autowireable via "CacheInterface $customThingCache"
282+ // uses the "app" cache configuration
283+ $cache->pool('custom_thing.cache')
284+ ->adapters(['cache.app']);
285+
286+ // creates a "my_cache_pool" service
287+ // autowireable via "CacheInterface $myCachePool"
288+ $cache->pool('my_cache_pool')
289+ ->adapters(['cache.adapter.filesystem']);
290+
291+ // uses the default_memcached_provider from above
292+ $cache->pool('acme.cache')
293+ ->adapters(['cache.adapter.memcached']);
294+
295+ // control adapter's configuration
296+ $cache->pool('foobar.cache')
297+ ->adapters(['cache.adapter.memcached'])
298+ ->provider('memcached://user:password@example.com');
299+
300+ $cache->pool('short_cache')
301+ ->adapters(['foobar.cache'])
302+ ->defaultLifetime(60);
303+ };
307304
308305 Each pool manages a set of independent cache keys: keys from different pools
309306*never * collide, even if they share the same backend. This is achieved by prefixing
@@ -442,26 +439,25 @@ and use that when configuring the pool.
442439
443440 // config/packages/cache.php
444441 use Symfony\Component\Cache\Adapter\RedisAdapter;
445-
446- $container->loadFromExtension('framework', [
447- 'cache' => [
448- 'pools' => [
449- 'cache.my_redis' => [
450- 'adapter' => 'cache.adapter.redis',
451- 'provider' => 'app.my_custom_redis_provider',
452- ],
453- ],
454- ],
455- ]);
456-
457- $container->register('app.my_custom_redis_provider', \Redis::class)
458- ->setFactory([RedisAdapter::class, 'createConnection'])
459- ->addArgument('redis://localhost')
460- ->addArgument([
461- 'retry_interval' => 2,
462- 'timeout' => 10
463- ])
464- ;
442+ use Symfony\Component\DependencyInjection\ContainerBuilder;
443+ use Symfony\Config\FrameworkConfig;
444+
445+ return static function (ContainerBuilder $container, FrameworkConfig $framework) {
446+ $framework->cache()
447+ ->pool('cache.my_redis')
448+ ->adapters(['cache.adapter.redis'])
449+ ->provider('app.my_custom_redis_provider');
450+
451+
452+ $container->register('app.my_custom_redis_provider', \Redis::class)
453+ ->setFactory([RedisAdapter::class, 'createConnection'])
454+ ->addArgument('redis://localhost')
455+ ->addArgument([
456+ 'retry_interval' => 2,
457+ 'timeout' => 10
458+ ])
459+ ;
460+ };
465461
466462 Creating a Cache Chain
467463----------------------
@@ -521,20 +517,19 @@ Symfony stores the item automatically in all the missing pools.
521517 ..code-block ::php
522518
523519 // config/packages/cache.php
524- $container->loadFromExtension('framework', [
525- 'cache' => [
526- 'pools' => [
527- 'my_cache_pool' => [
528- 'default_lifetime' => 31536000, // One year
529- 'adapters' => [
530- 'cache.adapter.array',
531- 'cache.adapter.apcu',
532- ['name' => 'cache.adapter.redis', 'provider' => 'redis://user:password@example.com'],
533- ],
534- ],
535- ],
536- ],
537- ]);
520+ use Symfony\Config\FrameworkConfig;
521+
522+ return static function (FrameworkConfig $framework) {
523+ $framework->cache()
524+ ->pool('my_cache_pool')
525+ ->defaultLifetime(31536000) // One year
526+ ->adapters([
527+ 'cache.adapter.array',
528+ 'cache.adapter.apcu',
529+ ['name' => 'cache.adapter.redis', 'provider' => 'redis://user:password@example.com'],
530+ ])
531+ ;
532+ };
538533
539534 Using Cache Tags
540535----------------
@@ -613,16 +608,15 @@ to enable this feature. This could be added by using the following configuration
613608 ..code-block ::php
614609
615610 // config/packages/cache.php
616- $container->loadFromExtension('framework', [
617- 'cache' => [
618- 'pools' => [
619- 'my_cache_pool' => [
620- 'adapter' => 'cache.adapter.redis',
621- 'tags' => true,
622- ],
623- ],
624- ],
625- ]);
611+ use Symfony\Config\FrameworkConfig;
612+
613+ return static function (FrameworkConfig $framework) {
614+ $framework->cache()
615+ ->pool('my_cache_pool')
616+ ->tags(true)
617+ ->adapters(['cache.adapter.redis'])
618+ ;
619+ };
626620
627621 Tags are stored in the same pool by default. This is good in most scenarios. But
628622sometimes it might be better to store the tags in a different pool. That could be
@@ -663,19 +657,20 @@ achieved by specifying the adapter.
663657 ..code-block ::php
664658
665659 // config/packages/cache.php
666- $container->loadFromExtension('framework', [
667- 'cache' => [
668- 'pools' => [
669- 'my_cache_pool' => [
670- 'adapter' => 'cache.adapter.redis',
671- 'tags' => 'tag_pool',
672- ],
673- 'tag_pool' => [
674- 'adapter' => 'cache.adapter.apcu',
675- ],
676- ],
677- ],
678- ]);
660+ use Symfony\Config\FrameworkConfig;
661+
662+ return static function (FrameworkConfig $framework) {
663+ $framework->cache()
664+ ->pool('my_cache_pool')
665+ ->tags('tag_pool')
666+ ->adapters(['cache.adapter.redis'])
667+ ;
668+
669+ $framework->cache()
670+ ->pool('tag_pool')
671+ ->adapters(['cache.adapter.apcu'])
672+ ;
673+ };
679674
680675 ..note ::
681676