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

[Cache] Show how to configure redis provider#11364

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Nyholm wants to merge5 commits intosymfony:3.4fromNyholm:issue-10989
Closed
Changes fromall 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
81 changes: 80 additions & 1 deletioncache.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,9 @@ of:
**Adapter**
An adapter is a *template* that you use to create Pools.
**Provider**
A provider is the DSN connection to the actual storage.
A provider is a service that some adapters are using to connect to the storage.
Redis and Memcached are example of such adapters. If a DSN is used as the
provider then a service is automatically created.

There are two pools that are always enabled by default. They are ``cache.app`` and
``cache.system``. The system cache is use for things like annotations, serializer,
Expand DownExpand Up@@ -315,6 +317,83 @@ For advanced configurations it could sometimes be useful to use a pool as an ada
],
]);

Custom Provider Options
-----------------------

Some providers have specific options that could be configured. The
:doc:`RedisAdapter </components/cache/adapters/redis_adapter>` allows you to create
providers with option ``timeout``, ``retry_interval`` etc. To use these options with non-default
values you need to create your own ``\Redis`` provider and use that when configuring
the pool.

.. configuration-block::

.. code-block:: yaml

# config/packages/cache.yaml
framework:
cache:
pools:
cache.my_redis:
adapter: cache.adapter.redis
provider: app.my_custom_redis_provider

services:
app.my_custom_redis_provider:
class: \Redis
factory: ['Symfony\Component\Cache\Adapter\RedisAdapter', 'createConnection']
arguments:
- 'redis://localhost'
- [ retry_interval: 2, timeout: 10 ]

.. code-block:: xml

<!-- config/packages/cache.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
https://symfony.com/schema/dic/services/services-1.0.xsd">

<framework:config>
<framework:cache>
<framework:pool name="cache.my_redis" adapter="cache.adapter.redis" provider="app.my_custom_redis_provider"/>
</framework:cache>
</framework:config>

<services>
<service id="app.my_custom_redis_provider" class="\Redis">
<argument>redis://localhost</argument>
<argument type="collection">
<argument key="retry_interval">2</argument>
<argument key="timeout">10</argument>
</argument>
</service>
</services>
</container>

.. code-block:: php

// config/packages/cache.php
$container->loadFromExtension('framework', [
'cache' => [
'pools' => [
'cache.my_redis' => [
'adapter' => 'cache.adapter.redis',
'provider' => 'app.my_custom_redis_provider',
],
],
],
]);

$container->getDefinition('app.my_custom_redis_provider', \Redis::class)
->addArgument('redis://localhost')
->addArgument([
'retry_interval' => 2,
'timeout' => 10
]);

Creating a Cache Chain
----------------------

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp