@@ -75,7 +75,9 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
7575 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
7676 xmlns : framework =" http://symfony.com/schema/dic/symfony"
7777 xsi : schemaLocation =" http://symfony.com/schema/dic/services
78- https://symfony.com/schema/dic/services/services-1.0.xsd" >
78+ https://symfony.com/schema/dic/services/services-1.0.xsd
79+ http://symfony.com/schema/dic/symfony
80+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
7981
8082 <framework : config >
8183 <framework : cache app =" cache.adapter.filesystem"
@@ -136,7 +138,9 @@ will create pool with service id of ``cache.[type]``
136138 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
137139 xmlns : framework =" http://symfony.com/schema/dic/symfony"
138140 xsi : schemaLocation =" http://symfony.com/schema/dic/services
139- https://symfony.com/schema/dic/services/services-1.0.xsd" >
141+ https://symfony.com/schema/dic/services/services-1.0.xsd
142+ http://symfony.com/schema/dic/symfony
143+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
140144
141145 <framework : config >
142146 <!--
@@ -146,6 +150,7 @@ will create pool with service id of ``cache.[type]``
146150 default_memcached_provider: Service: cache.memcached
147151 default_pdo_provider: Service: cache.pdo
148152 -->
153+ <!-- "directory" attribute is only used with cache.adapter.filesystem -->
149154 <framework : cache directory =" %kernel.cache_dir%/pools"
150155 default_doctrine_provider =" app.doctrine_cache"
151156 default_psr6_provider =" app.my_psr6_service"
@@ -226,14 +231,31 @@ You can also create more customized pools:
226231 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
227232 xmlns : framework =" http://symfony.com/schema/dic/symfony"
228233 xsi : schemaLocation =" http://symfony.com/schema/dic/services
229- https://symfony.com/schema/dic/services/services-1.0.xsd" >
234+ https://symfony.com/schema/dic/services/services-1.0.xsd
235+ http://symfony.com/schema/dic/symfony
236+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
230237
231238 <framework : config >
232- <framework : cache default_memcached_provider =" memcached://localhost" >
239+ <framework : cache default-memcached-provider =" memcached://localhost" >
240+ <!-- creates a "custom_thing.cache" service
241+ autowireable via "CacheInterface $customThingCache"
242+ uses the "app" cache configuration -->
233243 <framework : pool name =" custom_thing.cache" adapter =" cache.app" />
244+
245+ <!-- creates a "my_cache_pool" service
246+ autowireable via "CacheInterface $myCachePool" -->
234247 <framework : pool name =" my_cache_pool" adapter =" cache.adapter.array" />
248+
249+ <!-- uses the default_memcached_provider from above -->
235250 <framework : pool name =" acme.cache" adapter =" cache.adapter.memcached" />
236- <framework : pool name =" foobar.cache" adapter =" cache.adapter.memcached" provider =" memcached://user:password@example.com" />
251+
252+ <!-- control adapter's configuration -->
253+ <framework : pool name =" foobar.cache" adapter =" cache.adapter.memcached"
254+ provider =" memcached://user:password@example.com"
255+ />
256+
257+ <!-- uses the "foobar.cache" pool as its backend but controls
258+ the lifetime and (like all pools) has a separate cache namespace -->
237259 <framework : pool name =" short_cache" adapter =" foobar.cache" default-lifetime =" 60" />
238260 </framework : cache >
239261 </framework : config >
@@ -246,19 +268,32 @@ You can also create more customized pools:
246268 'cache' => [
247269 'default_memcached_provider' => 'memcached://localhost',
248270 'pools' => [
271+ // creates a "custom_thing.cache" service
272+ // autowireable via "CacheInterface $customThingCache"
273+ // uses the "app" cache configuration
249274 'custom_thing.cache' => [
250275 'adapter' => 'cache.app',
251276 ],
277+
278+ // creates a "my_cache_pool" service
279+ // autowireable via "CacheInterface $myCachePool"
252280 'my_cache_pool' => [
253281 'adapter' => 'cache.adapter.array',
254282 ],
283+
284+ // uses the default_memcached_provider from above
255285 'acme.cache' => [
256286 'adapter' => 'cache.adapter.memcached',
257287 ],
288+
289+ // control adapter's configuration
258290 'foobar.cache' => [
259291 'adapter' => 'cache.adapter.memcached',
260292 'provider' => 'memcached://user:password@example.com',
261293 ],
294+
295+ // uses the "foobar.cache" pool as its backend but controls
296+ // the lifetime and (like all pools) has a separate cache namespace
262297 'short_cache' => [
263298 'adapter' => 'foobar.cache',
264299 'default_lifetime' => 60,
@@ -331,7 +366,9 @@ and use that when configuring the pool.
331366 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
332367 xmlns : framework =" http://symfony.com/schema/dic/symfony"
333368 xsi : schemaLocation =" http://symfony.com/schema/dic/services
334- https://symfony.com/schema/dic/services/services-1.0.xsd" >
369+ https://symfony.com/schema/dic/services/services-1.0.xsd
370+ http://symfony.com/schema/dic/symfony
371+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
335372
336373 <framework : config >
337374 <framework : cache >
@@ -341,6 +378,7 @@ and use that when configuring the pool.
341378
342379 <services >
343380 <service id =" app.my_custom_redis_provider" class =" \Redis" >
381+ <factory class =" Symfony\Component\Cache\Adapter\RedisAdapter" method =" createConnection" />
344382 <argument >redis://localhost</argument >
345383 <argument type =" collection" >
346384 <argument key =" retry_interval" >2</argument >
@@ -353,6 +391,8 @@ and use that when configuring the pool.
353391 .. code-block :: php
354392
355393 // config/packages/cache.php
394+ use Symfony\Component\Cache\Adapter\RedisAdapter;
395+
356396 $container->loadFromExtension('framework', [
357397 'cache' => [
358398 'pools' => [
@@ -364,12 +404,14 @@ and use that when configuring the pool.
364404 ],
365405 ]);
366406
367- $container->getDefinition('app.my_custom_redis_provider', \Redis::class)
407+ $container->register('app.my_custom_redis_provider', \Redis::class)
408+ ->setFactory([RedisAdapter::class, 'createConnection'])
368409 ->addArgument('redis://localhost')
369410 ->addArgument([
370411 'retry_interval' => 2,
371412 'timeout' => 10
372- ]);
413+ ])
414+ ;
373415
374416 Creating a Cache Chain
375417----------------------
@@ -511,7 +553,9 @@ to enable this feature. This could be added by using the following configuration
511553 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
512554 xmlns : framework =" http://symfony.com/schema/dic/symfony"
513555 xsi : schemaLocation =" http://symfony.com/schema/dic/services
514- https://symfony.com/schema/dic/services/services-1.0.xsd" >
556+ https://symfony.com/schema/dic/services/services-1.0.xsd
557+ http://symfony.com/schema/dic/symfony
558+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
515559
516560 <framework : config >
517561 <framework : cache >
@@ -523,6 +567,9 @@ to enable this feature. This could be added by using the following configuration
523567 .. code-block :: php
524568
525569 // config/packages/cache.php
570+ use Symfony\Component\Cache\Adapter\ChainAdapter;
571+ use Symfony\Component\DependencyInjection\Reference;
572+
526573 $container->loadFromExtension('framework', [
527574 'cache' => [
528575 'pools' => [
0 commit comments