Skip to content

Commit 85bf97b

Browse files
yangbodong22011Simon Prickett
and
Simon Prickett
authored
doc: add defaults option example to cluster documentation (#2377)
* doc: add defaults option example to cluster documentation * Formatting update. * Formatting. Co-authored-by: Simon Prickett <simon@redis.com>
1 parent 29a2dc5 commit 85bf97b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/clustering.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ const value = await cluster.get('key');
4040
| modules | | Included [Redis Modules](../README.md#packages) |
4141
| scripts | | Script definitions (see [Lua Scripts](../README.md#lua-scripts)) |
4242
| functions | | Function definitions (see [Functions](../README.md#functions)) |
43+
## Auth with password and username
44+
45+
Specifying the password in the URL or a root node will only affect the connection to that specific node. In case you want to set the password for all the connections being created from a cluster instance, use the `defaults` option.
46+
```javascript
47+
createCluster({
48+
rootNodes: [{
49+
url: 'redis://10.0.0.1:30001'
50+
}, {
51+
url: 'redis://10.0.0.2:30002'
52+
}],
53+
defaults: {
54+
username: 'username',
55+
password: 'password'
56+
}
57+
});
58+
```
4359

4460
## Node Address Map
4561

0 commit comments

Comments
 (0)