@@ -59,18 +59,24 @@ helper method allows creating and configuring the Redis client class instance us
5959 'redis://localhost'
6060 );
6161
62- The DSN can specify either an IP/host (and an optional port) or a socket path, as
63- well as a database index. To enable TLS for connections, the scheme ``redis `` must
64- be replaced by ``rediss `` (the second ``s `` means "secure").
62+ The DSN can specify either an IP/host (and an optional port) or a socket path, as well as a
63+ password and a database index. To enable TLS for connections, the scheme ``redis `` must be
64+ replaced by ``rediss `` (the second ``s `` means "secure").
6565
6666.. note ::
6767
68- A `Data Source Name (DSN) `_ for this adapter must use the following format .
68+ A `Data Source Name (DSN) `_ for this adapter must use either one of the following formats .
6969
7070 .. code-block :: text
7171
7272 redis[s]://[pass@][ip|host|socket[:port]][/db-index]
7373
74+ .. code-block :: text
75+
76+ redis[s]:[[user]:pass@]?[ip|host|socket[:port]][¶ms]
77+
78+ Values for placeholders ``[user] ``, ``[:port] ``, ``[/db-index] `` and ``[¶ms] `` are optional.
79+
7480Below are common examples of valid DSNs showing a combination of available values::
7581
7682 use Symfony\Component\Cache\Adapter\RedisAdapter;
@@ -87,8 +93,11 @@ Below are common examples of valid DSNs showing a combination of available value
8793 // socket "/var/run/redis.sock" and auth "bad-pass"
8894 RedisAdapter::createConnection('redis://bad-pass@/var/run/redis.sock');
8995
90- // a single DSN can define multiple servers using the following syntax:
91- // host[hostname-or-IP:port] (where port is optional). Sockets must include a trailing ':'
96+ // host "redis1" (docker container) with alternate DSN syntax and selecting database index "3"
97+ RedisAdapter::createConnection('redis:?host[redis1:6379]&dbindex=3');
98+
99+ // providing credentials with alternate DSN syntax
100+ RedisAdapter::createConnection('redis:default:verysecurepassword@?host[redis1:6379]&dbindex=3');
92101
93102 // a single DSN can also define multiple servers
94103 RedisAdapter::createConnection(
@@ -103,6 +112,16 @@ parameter to set the name of your service group::
103112 'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
104113 );
105114
115+ // providing credentials
116+ RedisAdapter::createConnection(
117+ 'redis:default:verysecurepassword@?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
118+ );
119+
120+ // providing credentials and selecting database index "3"
121+ RedisAdapter::createConnection(
122+ 'redis:default:verysecurepassword@?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster&dbindex=3'
123+ );
124+
106125.. note ::
107126
108127 See the :class: `Symfony\\ Component\\ Cache\\ Traits\\ RedisTrait ` for more options
0 commit comments