Skip to content

Commit 8c98527

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: [Cache] Revert some changes merged made in 5.x branch
2 parents 8957e71 + bcef601 commit 8c98527

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

components/cache/adapters/redis_adapter.rst

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,24 @@ helper method allows creating and configuring the Redis client class instance us
5555
'redis://localhost'
5656
);
5757

58-
The DSN can specify either an IP/host (and an optional port) or a socket path, as
59-
well as a database index. To enable TLS for connections, the scheme ``redis`` must
60-
be replaced by ``rediss`` (the second ``s`` means "secure").
58+
The DSN can specify either an IP/host (and an optional port) or a socket path, as well as a
59+
password and a database index. To enable TLS for connections, the scheme ``redis`` must be
60+
replaced by ``rediss`` (the second ``s`` means "secure").
6161

6262
.. note::
6363

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

6666
.. code-block:: text
6767
6868
redis[s]://[pass@][ip|host|socket[:port]][/db-index]
6969
70+
.. code-block:: text
71+
72+
redis[s]:[[user]:pass@]?[ip|host|socket[:port]][&params]
73+
74+
Values for placeholders ``[user]``, ``[:port]``, ``[/db-index]`` and ``[&params]`` are optional.
75+
7076
Below are common examples of valid DSNs showing a combination of available values::
7177

7278
use Symfony\Component\Cache\Adapter\RedisAdapter;
@@ -83,8 +89,11 @@ Below are common examples of valid DSNs showing a combination of available value
8389
// socket "/var/run/redis.sock" and auth "bad-pass"
8490
RedisAdapter::createConnection('redis://bad-pass@/var/run/redis.sock');
8591

86-
// a single DSN can define multiple servers using the following syntax:
87-
// host[hostname-or-IP:port] (where port is optional). Sockets must include a trailing ':'
92+
// host "redis1" (docker container) with alternate DSN syntax and selecting database index "3"
93+
RedisAdapter::createConnection('redis:?host[redis1:6379]&dbindex=3');
94+
95+
// providing credentials with alternate DSN syntax
96+
RedisAdapter::createConnection('redis:default:verysecurepassword@?host[redis1:6379]&dbindex=3');
8897

8998
// a single DSN can also define multiple servers
9099
RedisAdapter::createConnection(
@@ -99,6 +108,16 @@ parameter to set the name of your service group::
99108
'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
100109
);
101110

111+
// providing credentials
112+
RedisAdapter::createConnection(
113+
'redis:default:verysecurepassword@?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
114+
);
115+
116+
// providing credentials and selecting database index "3"
117+
RedisAdapter::createConnection(
118+
'redis:default:verysecurepassword@?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster&dbindex=3'
119+
);
120+
102121
.. note::
103122

104123
See the :class:`Symfony\\Component\\Cache\\Traits\\RedisTrait` for more options

0 commit comments

Comments
 (0)