Skip to content

add example for cache pool configuration #10390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 59 additions & 2 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,57 @@ A list of cache pools to be created by the framework extension.

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

To configure a Redis cache pool with a default lifetime of 1 hour, do the following:

.. configuration-block::

.. code-block:: yaml

# config/packages/framework.yaml
framework:
cache:
pools:
cache.mycache:
adapter: cache.adapter.redis
default_lifetime: 3600

.. code-block:: xml

<!-- config/packages/framework.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:cache>
<framework:pool
name="cache.mycache"
adapter="cache.adapter.redis"
default-lifetime=3600
/>
</framework:cache>
<!-- ... -->
</framework:config>
</container>

.. code-block:: php

// config/packages/framework.php
$container->loadFromExtension('framework', array(
'cache' => array(
'pools' => array(
'cache.mycache' => array(
'adapter' => 'cache.adapter.redis',
'default_lifetime' => 3600,
),
),
),
));

.. _reference-cache-pools-name:

name
Expand All @@ -1973,7 +2024,10 @@ adapter

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

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

.. note::

Expand Down Expand Up @@ -2009,7 +2063,10 @@ provider

**type**: ``string``

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

clearer
"""""""
Expand Down