@@ -111,7 +111,7 @@ It helps with establishing a plain TCP/IP connection to Redis
111
111
and optionally authenticating (AUTH) and selecting the right database (SELECT).
112
112
113
113
``` php
114
- $factory->createClient('localhost:6379')->then(
114
+ $factory->createClient('redis:// localhost:6379')->then(
115
115
function (Client $client) {
116
116
// client connected (and authenticated)
117
117
},
@@ -121,26 +121,37 @@ $factory->createClient('localhost:6379')->then(
121
121
);
122
122
```
123
123
124
- You can omit the port if you're connecting to the default port 6379:
124
+ The ` $redisUri ` can be given in the form ` [redis://][:auth@]host[:port][/db] ` .
125
+ You can omit the URI scheme and port if you're connecting to the default port 6379:
125
126
126
127
``` php
128
+ // both are equivalent due to defaults being applied
127
129
$factory->createClient('localhost');
130
+ $factory->createClient('redis://localhost:6379');
128
131
```
129
132
130
- You can optionally include a password that will be used to authenticate (AUTH command) the client:
133
+ Redis supports password-based authentication (` AUTH ` command). Note that Redis'
134
+ authentication mechanism does not employ a username, so you can pass the
135
+ password "secret" as part of the URI like this:
131
136
132
137
``` php
133
- $factory->createClient('auth @localhost');
138
+ $factory->createClient('redis://ignored:secret @localhost');
134
139
```
135
140
141
+ > Legacy notice: The ` redis:// ` scheme is defined and preferred as of ` v1.2.0 ` .
142
+ For BC reasons, the ` Factory ` defaults to the ` tcp:// ` scheme in which case
143
+ the authentication details would include the otherwise unused username.
144
+ This legacy API will be removed in a future ` v2.0.0 ` version, so it's highly
145
+ recommended to upgrade to the above API.
146
+
136
147
You can optionally include a path that will be used to select (SELECT command) the right database:
137
148
138
149
``` php
139
- $factory->createClient('localhost/2');
150
+ $factory->createClient('redis:// localhost/2');
140
151
```
141
152
142
153
[ Deprecated] You can omit the complete URI if you want to connect to the default
143
- address ` localhost:6379 ` . This legacy API will be removed in a future
154
+ address ` redis:// localhost:6379` . This legacy API will be removed in a future
144
155
` v2.0.0 ` version, so it's highly recommended to upgrade to the above API.
145
156
146
157
``` php
0 commit comments