Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb0dc28f

Browse files
NyholmOskarStark
authored andcommitted
Document how to create cache pool with framework config
1 parentb4da05b commitb0dc28f

File tree

1 file changed

+21
-61
lines changed

1 file changed

+21
-61
lines changed

‎cache.rst‎

Lines 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:poolname="my_cache_pool"adapter="cache.adapter.array"/>
235235
<framework:poolname="acme.cache"adapter="cache.adapter.memcached"/>
236236
<framework:poolname="foobar.cache"adapter="cache.adapter.memcached"provider="memcached://user:password@example.com"/>
237-
<framework:poolname="short_cache"adapter="foobar.cache"default_lifetime="60"/>
237+
<framework:poolname="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:poolname="my_cache_pool"adapter="cache.adapter.psr6"provider="app.my_cache_chain_adapter"/>
423-
<framework:poolname="cache.my_redis"adapter="cache.adapter.redis"provider="redis://user:password@example.com"/>
424-
<framework:poolname="cache.apcu"adapter="cache.adapter.apcu"/>
425-
<framework:poolname="cache.array"adapter="cache.adapter.array"/>
414+
<framework:poolname="my_cache_pool"default-lifetime="31536000">
415+
<framework:adaptername="cache.adapter.array" />
416+
<framework:adaptername="cache.adapter.apcu" />
417+
<framework:adaptername="cache.adapter.redis"provider="redis://user:password@example.com" />
418+
</framework:pool>
426419
</framework:cache>
427420
</framework:config>
428-
429-
<services>
430-
<serviceid="app.my_cache_chain_adapter"class="Symfony\Component\Cache\Adapter\ChainAdapter">
431-
<argumenttype="collection">
432-
<argumenttype="service"value="cache.array"/>
433-
<argumenttype="service"value="cache.apcu"/>
434-
<argumenttype="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)

[8]ページ先頭

©2009-2025 Movatter.jp