Skip to content

Commit c2ce5ec

Browse files
committed
minor #10390 add example for cache pool configuration (dbu)
This PR was submitted for the master branch but it was squashed and merged into the 3.4 branch instead (closes #10390). Discussion ---------- add example for cache pool configuration the configuration reference on cache was quite unclear to me. this example should help to make it easier to understand Commits ------- 8de7cdb add example for cache pool configuration
2 parents 543bfb4 + 8de7cdb commit c2ce5ec

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

reference/configuration/framework.rst

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,57 @@ A list of cache pools to be created by the framework extension.
19521952

19531953
For more information about how pools works, see :ref:`cache pools <component-cache-cache-pools>`.
19541954

1955+
To configure a Redis cache pool with a default lifetime of 1 hour, do the following:
1956+
1957+
.. configuration-block::
1958+
1959+
.. code-block:: yaml
1960+
1961+
# config/packages/framework.yaml
1962+
framework:
1963+
cache:
1964+
pools:
1965+
cache.mycache:
1966+
adapter: cache.adapter.redis
1967+
default_lifetime: 3600
1968+
1969+
.. code-block:: xml
1970+
1971+
<!-- config/packages/framework.xml -->
1972+
<?xml version="1.0" encoding="UTF-8" ?>
1973+
<container xmlns="http://symfony.com/schema/dic/services"
1974+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1975+
xmlns:framework="http://symfony.com/schema/dic/symfony"
1976+
xsi:schemaLocation="http://symfony.com/schema/dic/services
1977+
http://symfony.com/schema/dic/services/services-1.0.xsd
1978+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1979+
1980+
<framework:config>
1981+
<framework:cache>
1982+
<framework:pool
1983+
name="cache.mycache"
1984+
adapter="cache.adapter.redis"
1985+
default-lifetime=3600
1986+
/>
1987+
</framework:cache>
1988+
<!-- ... -->
1989+
</framework:config>
1990+
</container>
1991+
1992+
.. code-block:: php
1993+
1994+
// config/packages/framework.php
1995+
$container->loadFromExtension('framework', array(
1996+
'cache' => array(
1997+
'pools' => array(
1998+
'cache.mycache' => array(
1999+
'adapter' => 'cache.adapter.redis',
2000+
'default_lifetime' => 3600,
2001+
),
2002+
),
2003+
),
2004+
));
2005+
19552006
.. _reference-cache-pools-name:
19562007

19572008
name
@@ -1970,7 +2021,10 @@ adapter
19702021

19712022
**type**: ``string`` **default**: ``cache.app``
19722023

1973-
The name of the adapter to use. You could also use your own implementation.
2024+
The service name of the adapter to use. You can specify one of the default
2025+
services that follow the pattern ``cache.adapter.[type]``. Alternatively you
2026+
can specify another cache pool as base, which will make this pool inherit the
2027+
settings from the base pool as defaults.
19742028

19752029
.. note::
19762030

@@ -1995,7 +2049,10 @@ provider
19952049

19962050
**type**: ``string``
19972051

1998-
The service name to use as provider when the specified adapter needs one.
2052+
Overwrite the default service name or DSN respectively, if you do not want to
2053+
use what is configured as ``default_X_provider`` under ``cache``. See the
2054+
description of the default provider setting above for the type of adapter
2055+
you use for information on how to specify the provider.
19992056

20002057
clearer
20012058
"""""""

0 commit comments

Comments
 (0)