@@ -71,7 +71,9 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
71
71
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
72
72
xmlns : framework =" http://symfony.com/schema/dic/symfony"
73
73
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" >
75
77
76
78
<framework : config >
77
79
<framework : cache app =" cache.adapter.filesystem"
@@ -132,7 +134,9 @@ will create pool with service id of ``cache.[type]``
132
134
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
133
135
xmlns : framework =" http://symfony.com/schema/dic/symfony"
134
136
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" >
136
140
137
141
<framework : config >
138
142
<!--
@@ -142,6 +146,7 @@ will create pool with service id of ``cache.[type]``
142
146
default_memcached_provider: Service: cache.memcached
143
147
default_pdo_provider: Service: cache.pdo
144
148
-->
149
+ <!-- "directory" attribute is only used with cache.adapter.filesystem -->
145
150
<framework : cache directory =" %kernel.cache_dir%/pools"
146
151
default_doctrine_provider =" app.doctrine_cache"
147
152
default_psr6_provider =" app.my_psr6_service"
@@ -222,14 +227,31 @@ You can also create more customized pools:
222
227
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
223
228
xmlns : framework =" http://symfony.com/schema/dic/symfony"
224
229
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" >
226
233
227
234
<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 -->
229
239
<framework : pool name =" custom_thing.cache" adapter =" cache.app" />
240
+
241
+ <!-- creates a "my_cache_pool" service
242
+ autowireable via "CacheInterface $myCachePool" -->
230
243
<framework : pool name =" my_cache_pool" adapter =" cache.adapter.array" />
244
+
245
+ <!-- uses the default_memcached_provider from above -->
231
246
<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 -->
233
255
<framework : pool name =" short_cache" adapter =" foobar.cache" default-lifetime =" 60" />
234
256
</framework : cache >
235
257
</framework : config >
@@ -242,19 +264,32 @@ You can also create more customized pools:
242
264
'cache' => [
243
265
'default_memcached_provider' => 'memcached://localhost',
244
266
'pools' => [
267
+ // creates a "custom_thing.cache" service
268
+ // autowireable via "CacheInterface $customThingCache"
269
+ // uses the "app" cache configuration
245
270
'custom_thing.cache' => [
246
271
'adapter' => 'cache.app',
247
272
],
273
+
274
+ // creates a "my_cache_pool" service
275
+ // autowireable via "CacheInterface $myCachePool"
248
276
'my_cache_pool' => [
249
277
'adapter' => 'cache.adapter.array',
250
278
],
279
+
280
+ // uses the default_memcached_provider from above
251
281
'acme.cache' => [
252
282
'adapter' => 'cache.adapter.memcached',
253
283
],
284
+
285
+ // control adapter's configuration
254
286
'foobar.cache' => [
255
287
'adapter' => 'cache.adapter.memcached',
256
288
'provider' => 'memcached://user:[email protected] ',
257
289
],
290
+
291
+ // uses the "foobar.cache" pool as its backend but controls
292
+ // the lifetime and (like all pools) has a separate cache namespace
258
293
'short_cache' => [
259
294
'adapter' => 'foobar.cache',
260
295
'default_lifetime' => 60,
@@ -327,7 +362,9 @@ and use that when configuring the pool.
327
362
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
328
363
xmlns : framework =" http://symfony.com/schema/dic/symfony"
329
364
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" >
331
368
332
369
<framework : config >
333
370
<framework : cache >
@@ -337,6 +374,7 @@ and use that when configuring the pool.
337
374
338
375
<services >
339
376
<service id =" app.my_custom_redis_provider" class =" \Redis" >
377
+ <factory class =" Symfony\Component\Cache\Adapter\RedisAdapter" method =" createConnection" />
340
378
<argument >redis://localhost</argument >
341
379
<argument type =" collection" >
342
380
<argument key =" retry_interval" >2</argument >
@@ -349,6 +387,8 @@ and use that when configuring the pool.
349
387
.. code-block :: php
350
388
351
389
// config/packages/cache.php
390
+ use Symfony\Component\Cache\Adapter\RedisAdapter;
391
+
352
392
$container->loadFromExtension('framework', [
353
393
'cache' => [
354
394
'pools' => [
@@ -360,12 +400,14 @@ and use that when configuring the pool.
360
400
],
361
401
]);
362
402
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'])
364
405
->addArgument('redis://localhost')
365
406
->addArgument([
366
407
'retry_interval' => 2,
367
408
'timeout' => 10
368
- ]);
409
+ ])
410
+ ;
369
411
370
412
Creating a Cache Chain
371
413
----------------------
@@ -503,7 +545,9 @@ to enable this feature. This could be added by using the following configuration
503
545
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
504
546
xmlns : framework =" http://symfony.com/schema/dic/symfony"
505
547
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" >
507
551
508
552
<framework : config >
509
553
<framework : cache >
@@ -515,6 +559,9 @@ to enable this feature. This could be added by using the following configuration
515
559
.. code-block :: php
516
560
517
561
// config/packages/cache.php
562
+ use Symfony\Component\Cache\Adapter\ChainAdapter;
563
+ use Symfony\Component\DependencyInjection\Reference;
564
+
518
565
$container->loadFromExtension('framework', [
519
566
'cache' => [
520
567
'pools' => [
0 commit comments