@@ -71,7 +71,9 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
7171 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
7272 xmlns : framework =" http://symfony.com/schema/dic/symfony"
7373 xsi : schemaLocation =" http://symfony.com/schema/dic/services
74- https://symfony.com/schema/dic/services/services-1.0.xsd" >
74+ https://symfony.com/schema/dic/services/services-1.0.xsd
75+ http://symfony.com/schema/dic/symfony
76+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
7577
7678 <framework : config >
7779 <framework : cache app =" cache.adapter.filesystem"
@@ -132,7 +134,9 @@ will create pool with service id of ``cache.[type]``
132134 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
133135 xmlns : framework =" http://symfony.com/schema/dic/symfony"
134136 xsi : schemaLocation =" http://symfony.com/schema/dic/services
135- https://symfony.com/schema/dic/services/services-1.0.xsd" >
137+ https://symfony.com/schema/dic/services/services-1.0.xsd
138+ http://symfony.com/schema/dic/symfony
139+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
136140
137141 <framework : config >
138142 <!--
@@ -142,6 +146,7 @@ will create pool with service id of ``cache.[type]``
142146 default_memcached_provider: Service: cache.memcached
143147 default_pdo_provider: Service: cache.pdo
144148 -->
149+ <!-- "directory" attribute is only used with cache.adapter.filesystem -->
145150 <framework : cache directory =" %kernel.cache_dir%/pools"
146151 default_doctrine_provider =" app.doctrine_cache"
147152 default_psr6_provider =" app.my_psr6_service"
@@ -222,14 +227,31 @@ You can also create more customized pools:
222227 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
223228 xmlns : framework =" http://symfony.com/schema/dic/symfony"
224229 xsi : schemaLocation =" http://symfony.com/schema/dic/services
225- https://symfony.com/schema/dic/services/services-1.0.xsd" >
230+ https://symfony.com/schema/dic/services/services-1.0.xsd
231+ http://symfony.com/schema/dic/symfony
232+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
226233
227234 <framework : config >
228- <framework : cache default_memcached_provider =" memcached://localhost" >
235+ <framework : cache default-memcached-provider =" memcached://localhost" >
236+ <!-- creates a "custom_thing.cache" service
237+ autowireable via "CacheInterface $customThingCache"
238+ uses the "app" cache configuration -->
229239 <framework : pool name =" custom_thing.cache" adapter =" cache.app" />
240+
241+ <!-- creates a "my_cache_pool" service
242+ autowireable via "CacheInterface $myCachePool" -->
230243 <framework : pool name =" my_cache_pool" adapter =" cache.adapter.array" />
244+
245+ <!-- uses the default_memcached_provider from above -->
231246 <framework : pool name =" acme.cache" adapter =" cache.adapter.memcached" />
232- <framework : pool name =" foobar.cache" adapter =" cache.adapter.memcached" provider =" memcached://user:[email protected] " /> 247+
248+ <!-- control adapter's configuration -->
249+ <framework : pool name =" foobar.cache" adapter =" cache.adapter.memcached"
250+ provider =" memcached://user:[email protected] " 251+ />
252+
253+ <!-- uses the "foobar.cache" pool as its backend but controls
254+ the lifetime and (like all pools) has a separate cache namespace -->
233255 <framework : pool name =" short_cache" adapter =" foobar.cache" default-lifetime =" 60" />
234256 </framework : cache >
235257 </framework : config >
@@ -242,19 +264,32 @@ You can also create more customized pools:
242264 'cache' => [
243265 'default_memcached_provider' => 'memcached://localhost',
244266 'pools' => [
267+ // creates a "custom_thing.cache" service
268+ // autowireable via "CacheInterface $customThingCache"
269+ // uses the "app" cache configuration
245270 'custom_thing.cache' => [
246271 'adapter' => 'cache.app',
247272 ],
273+
274+ // creates a "my_cache_pool" service
275+ // autowireable via "CacheInterface $myCachePool"
248276 'my_cache_pool' => [
249277 'adapter' => 'cache.adapter.array',
250278 ],
279+
280+ // uses the default_memcached_provider from above
251281 'acme.cache' => [
252282 'adapter' => 'cache.adapter.memcached',
253283 ],
284+
285+ // control adapter's configuration
254286 'foobar.cache' => [
255287 'adapter' => 'cache.adapter.memcached',
256288 'provider' => 'memcached://user:[email protected] ', 257289 ],
290+
291+ // uses the "foobar.cache" pool as its backend but controls
292+ // the lifetime and (like all pools) has a separate cache namespace
258293 'short_cache' => [
259294 'adapter' => 'foobar.cache',
260295 'default_lifetime' => 60,
@@ -327,7 +362,9 @@ and use that when configuring the pool.
327362 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
328363 xmlns : framework =" http://symfony.com/schema/dic/symfony"
329364 xsi : schemaLocation =" http://symfony.com/schema/dic/services
330- https://symfony.com/schema/dic/services/services-1.0.xsd" >
365+ https://symfony.com/schema/dic/services/services-1.0.xsd
366+ http://symfony.com/schema/dic/symfony
367+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
331368
332369 <framework : config >
333370 <framework : cache >
@@ -337,6 +374,7 @@ and use that when configuring the pool.
337374
338375 <services >
339376 <service id =" app.my_custom_redis_provider" class =" \Redis" >
377+ <factory class =" Symfony\Component\Cache\Adapter\RedisAdapter" method =" createConnection" />
340378 <argument >redis://localhost</argument >
341379 <argument type =" collection" >
342380 <argument key =" retry_interval" >2</argument >
@@ -349,6 +387,8 @@ and use that when configuring the pool.
349387 .. code-block :: php
350388
351389 // config/packages/cache.php
390+ use Symfony\Component\Cache\Adapter\RedisAdapter;
391+
352392 $container->loadFromExtension('framework', [
353393 'cache' => [
354394 'pools' => [
@@ -360,12 +400,14 @@ and use that when configuring the pool.
360400 ],
361401 ]);
362402
363- $container->getDefinition('app.my_custom_redis_provider', \Redis::class)
403+ $container->register('app.my_custom_redis_provider', \Redis::class)
404+ ->setFactory([RedisAdapter::class, 'createConnection'])
364405 ->addArgument('redis://localhost')
365406 ->addArgument([
366407 'retry_interval' => 2,
367408 'timeout' => 10
368- ]);
409+ ])
410+ ;
369411
370412 Creating a Cache Chain
371413----------------------
@@ -503,7 +545,9 @@ to enable this feature. This could be added by using the following configuration
503545 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
504546 xmlns : framework =" http://symfony.com/schema/dic/symfony"
505547 xsi : schemaLocation =" http://symfony.com/schema/dic/services
506- https://symfony.com/schema/dic/services/services-1.0.xsd" >
548+ https://symfony.com/schema/dic/services/services-1.0.xsd
549+ http://symfony.com/schema/dic/symfony
550+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
507551
508552 <framework : config >
509553 <framework : cache >
@@ -515,6 +559,9 @@ to enable this feature. This could be added by using the following configuration
515559 .. code-block :: php
516560
517561 // config/packages/cache.php
562+ use Symfony\Component\Cache\Adapter\ChainAdapter;
563+ use Symfony\Component\DependencyInjection\Reference;
564+
518565 $container->loadFromExtension('framework', [
519566 'cache' => [
520567 'pools' => [
0 commit comments