@@ -53,16 +53,16 @@ helper method allows creating and configuring the Redis client class instance us
53
53
'redis://localhost'
54
54
);
55
55
56
- The DSN can specify either an IP/host (and an optional port) or a socket path, as well as a user
57
- and password and a database index.
56
+ The DSN can specify either an IP/host (and an optional port) or a socket path, as well as a
57
+ password and a database index.
58
58
59
59
.. note ::
60
60
61
61
A `Data Source Name (DSN) `_ for this adapter must use the following format.
62
62
63
63
.. code-block :: text
64
64
65
- redis://[user: pass@][ip|host|socket[:port]][/db-index]
65
+ redis://[pass@][ip|host|socket[:port]][/db-index]
66
66
67
67
Below are common examples of valid DSNs showing a combination of available values::
68
68
@@ -74,11 +74,26 @@ Below are common examples of valid DSNs showing a combination of available value
74
74
// host "my.server.com" and port "6379" and database index "20"
75
75
RedisAdapter::createConnection('redis://my.server.com:6379/20');
76
76
77
- // host "localhost" and SASL use "rmf " and pass "abcdef"
78
- RedisAdapter::createConnection('redis://rmf: abcdef@localhost');
77
+ // host "localhost", auth "abcdef " and timeout 5 seconds
78
+ RedisAdapter::createConnection('redis://abcdef@localhost?timeout=5 ');
79
79
80
- // socket "/var/run/redis.sock" and SASL user "user1" and pass "bad-pass"
81
- RedisAdapter::createConnection('redis://user1:bad-pass@/var/run/redis.sock');
80
+ // socket "/var/run/redis.sock" and auth "bad-pass"
81
+ RedisAdapter::createConnection('redis://bad-pass@/var/run/redis.sock');
82
+
83
+ // a single DSN can define multiple servers using the following syntax:
84
+ // host[hostname-or-IP:port] (where port is optional). Sockets must include a trailing ':'
85
+ RedisAdapter::createConnection(
86
+ 'redis:?host[localhost]&host[localhost:6379]&host[/var/run/redis.sock:]&auth=my-password&redis_cluster=1'
87
+ );
88
+
89
+ .. versionadded :: 4.2
90
+
91
+ The option to define multiple servers in a single DSN was introduced in Symfony 4.2.
92
+
93
+ .. note ::
94
+
95
+ See the :class: `Symfony\\ Component\\ Cache\\ Traits\\ RedisTrait ` for more options
96
+ you can pass as DSN parameters.
82
97
83
98
Configure the Options
84
99
---------------------
0 commit comments