Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 707d1bd

Browse filesBrowse files
committed
minor #11855 Document how to create cache pool with framework config (Nyholm)
This PR was submitted for the master branch but it was squashed and merged into the 4.4 branch instead (closes #11855). Discussion ---------- Document how to create cache pool with framework config This is some docs for symfony/symfony#32294 I removed the "old" way of doing it because this is far better. Commits ------- b0dc28f Document how to create cache pool with framework config
2 parents b4da05b + b0dc28f commit 707d1bd
Copy full SHA for 707d1bd

File tree

1 file changed

+21
-61
lines changed
Filter options

1 file changed

+21
-61
lines changed

‎cache.rst

Copy file name to clipboardExpand all lines: cache.rst
+21-61Lines changed: 21 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ You can also create more customized pools:
234234
<framework:pool name="my_cache_pool" adapter="cache.adapter.array"/>
235235
<framework:pool name="acme.cache" adapter="cache.adapter.memcached"/>
236236
<framework:pool name="foobar.cache" adapter="cache.adapter.memcached" provider="memcached://user:password@example.com"/>
237-
<framework:pool name="short_cache" adapter="foobar.cache" default_lifetime="60"/>
237+
<framework:pool name="short_cache" adapter="foobar.cache" default-lifetime="60"/>
238238
</framework:cache>
239239
</framework:config>
240240
</container>
@@ -380,6 +380,10 @@ To get the best of both worlds you may use a chain of adapters. The idea is to
380380
first look at the quick adapter and then move on to slower adapters. In the worst
381381
case the value needs to be recalculated.
382382

383+
.. versionadded:: 4.4
384+
385+
Support for configuring a chain using ``framework.cache.pools`` was introduced in Symfony 4.4.
386+
383387
.. configuration-block::
384388

385389
.. code-block:: yaml
@@ -389,23 +393,11 @@ case the value needs to be recalculated.
389393
cache:
390394
pools:
391395
my_cache_pool:
392-
adapter: cache.adapter.psr6
393-
provider: app.my_cache_chain_adapter
394-
cache.my_redis:
395-
adapter: cache.adapter.redis
396-
provider: 'redis://user:password@example.com'
397-
cache.apcu:
398-
adapter: cache.adapter.apcu
399-
cache.array:
400-
adapter: cache.adapter.array
401-
402-
403-
services:
404-
app.my_cache_chain_adapter:
405-
class: Symfony\Component\Cache\Adapter\ChainAdapter
406-
arguments:
407-
- ['@cache.array', '@cache.apcu', '@cache.my_redis']
408-
- 31536000 # One year
396+
default_lifetime: 31536000 # One year
397+
adapters:
398+
- cache.adapter.array
399+
- cache.adapter.apcu
400+
- {name: cache.adapter.redis, provider: 'redis://user:password@example.com'}
409401
410402
.. code-block:: xml
411403
@@ -419,23 +411,13 @@ case the value needs to be recalculated.
419411
420412
<framework:config>
421413
<framework:cache>
422-
<framework:pool name="my_cache_pool" adapter="cache.adapter.psr6" provider="app.my_cache_chain_adapter"/>
423-
<framework:pool name="cache.my_redis" adapter="cache.adapter.redis" provider="redis://user:password@example.com"/>
424-
<framework:pool name="cache.apcu" adapter="cache.adapter.apcu"/>
425-
<framework:pool name="cache.array" adapter="cache.adapter.array"/>
414+
<framework:pool name="my_cache_pool" default-lifetime="31536000">
415+
<framework:adapter name="cache.adapter.array" />
416+
<framework:adapter name="cache.adapter.apcu" />
417+
<framework:adapter name="cache.adapter.redis" provider="redis://user:password@example.com" />
418+
</framework:pool>
426419
</framework:cache>
427420
</framework:config>
428-
429-
<services>
430-
<service id="app.my_cache_chain_adapter" class="Symfony\Component\Cache\Adapter\ChainAdapter">
431-
<argument type="collection">
432-
<argument type="service" value="cache.array"/>
433-
<argument type="service" value="cache.apcu"/>
434-
<argument type="service" value="cache.my_redis"/>
435-
</argument>
436-
<argument>31536000</argument>
437-
</service>
438-
</services>
439421
</container>
440422
441423
.. code-block:: php
@@ -445,39 +427,17 @@ case the value needs to be recalculated.
445427
'cache' => [
446428
'pools' => [
447429
'my_cache_pool' => [
448-
'adapter' => 'cache.adapter.psr6',
449-
'provider' => 'app.my_cache_chain_adapter',
450-
],
451-
'cache.my_redis' => [
452-
'adapter' => 'cache.adapter.redis',
453-
'provider' => 'redis://user:password@example.com',
454-
],
455-
'cache.apcu' => [
456-
'adapter' => 'cache.adapter.apcu',
457-
],
458-
'cache.array' => [
459-
'adapter' => 'cache.adapter.array',
430+
'default_lifetime' => 31536000, // One year
431+
'adapters' => [
432+
'cache.adapter.array',
433+
'cache.adapter.apcu',
434+
['name' => 'cache.adapter.redis', 'provider' => 'redis://user:password@example.com'],
435+
],
460436
],
461437
],
462438
],
463439
]);
464440
465-
$container->getDefinition('app.my_cache_chain_adapter', \Symfony\Component\Cache\Adapter\ChainAdapter::class)
466-
->addArgument([
467-
new Reference('cache.array'),
468-
new Reference('cache.apcu'),
469-
new Reference('cache.my_redis'),
470-
])
471-
->addArgument(31536000);
472-
473-
.. note::
474-
475-
In this configuration the ``my_cache_pool`` pool is using the ``cache.adapter.psr6``
476-
adapter and the ``app.my_cache_chain_adapter`` service as a provider. That is
477-
because ``ChainAdapter`` does not support the ``cache.pool`` tag. So it is decorated
478-
with the ``ProxyAdapter``.
479-
480-
481441
Using Cache Tags
482442
----------------
483443

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.