@@ -75,7 +75,9 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
75
75
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
76
76
xmlns : framework =" http://symfony.com/schema/dic/symfony"
77
77
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" >
79
81
80
82
<framework : config >
81
83
<framework : cache app =" cache.adapter.filesystem"
@@ -136,7 +138,9 @@ will create pool with service id of ``cache.[type]``
136
138
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
137
139
xmlns : framework =" http://symfony.com/schema/dic/symfony"
138
140
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" >
140
144
141
145
<framework : config >
142
146
<!--
@@ -146,6 +150,7 @@ will create pool with service id of ``cache.[type]``
146
150
default_memcached_provider: Service: cache.memcached
147
151
default_pdo_provider: Service: cache.pdo
148
152
-->
153
+ <!-- "directory" attribute is only used with cache.adapter.filesystem -->
149
154
<framework : cache directory =" %kernel.cache_dir%/pools"
150
155
default_doctrine_provider =" app.doctrine_cache"
151
156
default_psr6_provider =" app.my_psr6_service"
@@ -226,14 +231,31 @@ You can also create more customized pools:
226
231
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
227
232
xmlns : framework =" http://symfony.com/schema/dic/symfony"
228
233
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" >
230
237
231
238
<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 -->
233
243
<framework : pool name =" custom_thing.cache" adapter =" cache.app" />
244
+
245
+ <!-- creates a "my_cache_pool" service
246
+ autowireable via "CacheInterface $myCachePool" -->
234
247
<framework : pool name =" my_cache_pool" adapter =" cache.adapter.array" />
248
+
249
+ <!-- uses the default_memcached_provider from above -->
235
250
<framework : pool name =" acme.cache" adapter =" cache.adapter.memcached" />
236
- <framework : pool name =" foobar.cache" adapter =" cache.adapter.memcached" provider =" memcached://user:[email protected] " />
251
+
252
+ <!-- control adapter's configuration -->
253
+ <framework : pool name =" foobar.cache" adapter =" cache.adapter.memcached"
254
+ provider =" memcached://user:[email protected] "
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 -->
237
259
<framework : pool name =" short_cache" adapter =" foobar.cache" default-lifetime =" 60" />
238
260
</framework : cache >
239
261
</framework : config >
@@ -246,19 +268,32 @@ You can also create more customized pools:
246
268
'cache' => [
247
269
'default_memcached_provider' => 'memcached://localhost',
248
270
'pools' => [
271
+ // creates a "custom_thing.cache" service
272
+ // autowireable via "CacheInterface $customThingCache"
273
+ // uses the "app" cache configuration
249
274
'custom_thing.cache' => [
250
275
'adapter' => 'cache.app',
251
276
],
277
+
278
+ // creates a "my_cache_pool" service
279
+ // autowireable via "CacheInterface $myCachePool"
252
280
'my_cache_pool' => [
253
281
'adapter' => 'cache.adapter.array',
254
282
],
283
+
284
+ // uses the default_memcached_provider from above
255
285
'acme.cache' => [
256
286
'adapter' => 'cache.adapter.memcached',
257
287
],
288
+
289
+ // control adapter's configuration
258
290
'foobar.cache' => [
259
291
'adapter' => 'cache.adapter.memcached',
260
292
'provider' => 'memcached://user:[email protected] ',
261
293
],
294
+
295
+ // uses the "foobar.cache" pool as its backend but controls
296
+ // the lifetime and (like all pools) has a separate cache namespace
262
297
'short_cache' => [
263
298
'adapter' => 'foobar.cache',
264
299
'default_lifetime' => 60,
@@ -331,7 +366,9 @@ and use that when configuring the pool.
331
366
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
332
367
xmlns : framework =" http://symfony.com/schema/dic/symfony"
333
368
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" >
335
372
336
373
<framework : config >
337
374
<framework : cache >
@@ -341,6 +378,7 @@ and use that when configuring the pool.
341
378
342
379
<services >
343
380
<service id =" app.my_custom_redis_provider" class =" \Redis" >
381
+ <factory class =" Symfony\Component\Cache\Adapter\RedisAdapter" method =" createConnection" />
344
382
<argument >redis://localhost</argument >
345
383
<argument type =" collection" >
346
384
<argument key =" retry_interval" >2</argument >
@@ -353,6 +391,8 @@ and use that when configuring the pool.
353
391
.. code-block :: php
354
392
355
393
// config/packages/cache.php
394
+ use Symfony\Component\Cache\Adapter\RedisAdapter;
395
+
356
396
$container->loadFromExtension('framework', [
357
397
'cache' => [
358
398
'pools' => [
@@ -364,12 +404,14 @@ and use that when configuring the pool.
364
404
],
365
405
]);
366
406
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'])
368
409
->addArgument('redis://localhost')
369
410
->addArgument([
370
411
'retry_interval' => 2,
371
412
'timeout' => 10
372
- ]);
413
+ ])
414
+ ;
373
415
374
416
Creating a Cache Chain
375
417
----------------------
@@ -511,7 +553,9 @@ to enable this feature. This could be added by using the following configuration
511
553
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
512
554
xmlns : framework =" http://symfony.com/schema/dic/symfony"
513
555
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" >
515
559
516
560
<framework : config >
517
561
<framework : cache >
@@ -523,6 +567,9 @@ to enable this feature. This could be added by using the following configuration
523
567
.. code-block :: php
524
568
525
569
// config/packages/cache.php
570
+ use Symfony\Component\Cache\Adapter\ChainAdapter;
571
+ use Symfony\Component\DependencyInjection\Reference;
572
+
526
573
$container->loadFromExtension('framework', [
527
574
'cache' => [
528
575
'pools' => [
0 commit comments