Skip to content

Commit b1242c8

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: Removing heading fixes #16310 unclear alternate DSN format
2 parents 2eee2d0 + 7e1f09f commit b1242c8

File tree

2 files changed

+62
-17
lines changed

2 files changed

+62
-17
lines changed

components/cache/adapters/redis_adapter.rst

+62-15
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,18 @@ replaced by ``rediss`` (the second ``s`` means "secure").
6767

6868
.. note::
6969

70-
A `Data Source Name (DSN)`_ for this adapter must use the following format.
70+
A `Data Source Name (DSN)`_ for this adapter must use either one of the following formats.
7171

7272
.. code-block:: text
7373
7474
redis[s]://[pass@][ip|host|socket[:port]][/db-index]
7575
76+
.. code-block:: text
77+
78+
redis[s]:[[user]:pass@]?[ip|host|socket[:port]][&params]
79+
80+
Values for placeholders ``[user]``, ``[:port]``, ``[/db-index]`` and ``[&params]`` are optional.
81+
7682
Below are common examples of valid DSNs showing a combination of available values::
7783

7884
use Symfony\Component\Cache\Adapter\RedisAdapter;
@@ -89,8 +95,13 @@ Below are common examples of valid DSNs showing a combination of available value
8995
// socket "/var/run/redis.sock" and auth "bad-pass"
9096
RedisAdapter::createConnection('redis://bad-pass@/var/run/redis.sock');
9197

92-
// a single DSN can define multiple servers using the following syntax:
93-
// host[hostname-or-IP:port] (where port is optional). Sockets must include a trailing ':'
98+
// host "redis1" (docker container) with alternate DSN syntax and selecting database index "3"
99+
RedisAdapter::createConnection('redis:?host[redis1:6379]&dbindex=3');
100+
101+
// providing credentials with alternate DSN syntax
102+
RedisAdapter::createConnection('redis:default:verysecurepassword@?host[redis1:6379]&dbindex=3');
103+
104+
// a single DSN can also define multiple servers
94105
RedisAdapter::createConnection(
95106
'redis:?host[localhost]&host[localhost:6379]&host[/var/run/redis.sock:]&auth=my-password&redis_cluster=1'
96107
);
@@ -103,6 +114,16 @@ parameter to set the name of your service group::
103114
'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
104115
);
105116

117+
// providing credentials
118+
RedisAdapter::createConnection(
119+
'redis:default:verysecurepassword@?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
120+
);
121+
122+
// providing credentials and selecting database index "3"
123+
RedisAdapter::createConnection(
124+
'redis:default:verysecurepassword@?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster&dbindex=3'
125+
);
126+
106127
.. note::
107128

108129
See the :class:`Symfony\\Component\\Cache\\Traits\\RedisTrait` for more options
@@ -124,29 +145,31 @@ array of ``key => value`` pairs representing option names and their respective v
124145

125146
// associative array of configuration options
126147
[
127-
'lazy' => false,
148+
'class' => null,
128149
'persistent' => 0,
129150
'persistent_id' => null,
130-
'tcp_keepalive' => 0,
131151
'timeout' => 30,
132152
'read_timeout' => 0,
133153
'retry_interval' => 0,
154+
'tcp_keepalive' => 0,
155+
'lazy' => null,
156+
'redis_cluster' => false,
157+
'redis_sentinel' => null,
158+
'dbindex' => 0,
159+
'failover' => 'none',
160+
'ssl' => null,
134161
]
135162

136163
);
137164

138165
Available Options
139166
~~~~~~~~~~~~~~~~~
140167

141-
``class`` (type: ``string``)
168+
``class`` (type: ``string``, default: ``null``)
142169
Specifies the connection library to return, either ``\Redis`` or ``\Predis\Client``.
143170
If none is specified, it will return ``\Redis`` if the ``redis`` extension is
144-
available, and ``\Predis\Client`` otherwise.
145-
146-
``lazy`` (type: ``bool``, default: ``false``)
147-
Enables or disables lazy connections to the backend. It's ``false`` by
148-
default when using this as a stand-alone component and ``true`` by default
149-
when using it inside a Symfony application.
171+
available, and ``\Predis\Client`` otherwise. Explicitly set this to ``\Predis\Client`` for Sentinel if you are
172+
running into issues when retrieving master information.
150173

151174
``persistent`` (type: ``int``, default: ``0``)
152175
Enables or disables use of persistent connections. A value of ``0`` disables persistent
@@ -155,6 +178,10 @@ Available Options
155178
``persistent_id`` (type: ``string|null``, default: ``null``)
156179
Specifies the persistent id string to use for a persistent connection.
157180

181+
``timeout`` (type: ``int``, default: ``30``)
182+
Specifies the time (in seconds) used to connect to a Redis server before the
183+
connection attempt times out.
184+
158185
``read_timeout`` (type: ``int``, default: ``0``)
159186
Specifies the time (in seconds) used when performing read operations on the underlying
160187
network resource before the operation times out.
@@ -167,9 +194,28 @@ Available Options
167194
Specifies the `TCP-keepalive`_ timeout (in seconds) of the connection. This
168195
requires phpredis v4 or higher and a TCP-keepalive enabled server.
169196

170-
``timeout`` (type: ``int``, default: ``30``)
171-
Specifies the time (in seconds) used to connect to a Redis server before the
172-
connection attempt times out.
197+
``lazy`` (type: ``bool``, default: ``null``)
198+
Enables or disables lazy connections to the backend. It's ``false`` by
199+
default when using this as a stand-alone component and ``true`` by default
200+
when using it inside a Symfony application.
201+
202+
``redis_cluster`` (type: ``bool``, default: ``false``)
203+
Enables or disables redis cluster. The actual value passed is irrelevant as long as it passes loose comparison
204+
checks: `redis_cluster=1` will suffice.
205+
206+
``redis_sentinel`` (type: ``string``, default: ``null``)
207+
Specifies the master name connected to the sentinels.
208+
209+
``dbindex`` (type: ``int``, default: ``0``)
210+
Specifies the database index to select.
211+
212+
``failover`` (type: ``string``, default: ``none``)
213+
Specifies failover for cluster implementations. For ``\RedisCluster`` valid options are ``none`` (default),
214+
``error``, ``distribute`` or ``slaves``. For ``\Predis\ClientInterface`` valid options are ``slaves``
215+
or ``distribute``.
216+
217+
``ssl`` (type: ``bool``, default: ``null``)
218+
SSL context options. See `php.net/context.ssl`_ for more information.
173219

174220
.. note::
175221

@@ -217,3 +263,4 @@ Read more about this topic in the official `Redis LRU Cache Documentation`_.
217263
.. _`TCP-keepalive`: https://redis.io/topics/clients#tcp-keepalive
218264
.. _`Redis Sentinel`: https://redis.io/topics/sentinel
219265
.. _`Redis LRU Cache Documentation`: https://redis.io/topics/lru-cache
266+
.. _`php.net/context.ssl`: https://php.net/context.ssl

form/form_collections.rst

-2
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,6 @@ Now, you need to put some code into the ``removeTag()`` method of ``Task``::
524524
}
525525
}
526526

527-
Template Modifications
528-
~~~~~~~~~~~~~~~~~~~~~~
529527

530528
The ``allow_delete`` option means that if an item of a collection
531529
isn't sent on submission, the related data is removed from the collection

0 commit comments

Comments
 (0)