You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
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>
This commit is contained in:
@@ -40,6 +40,22 @@ const value = await cluster.get('key');
|
|||||||
| modules | | Included [Redis Modules](../README.md#packages) |
|
| modules | | Included [Redis Modules](../README.md#packages) |
|
||||||
| scripts | | Script definitions (see [Lua Scripts](../README.md#lua-scripts)) |
|
| scripts | | Script definitions (see [Lua Scripts](../README.md#lua-scripts)) |
|
||||||
| functions | | Function definitions (see [Functions](../README.md#functions)) |
|
| functions | | Function definitions (see [Functions](../README.md#functions)) |
|
||||||
|
## Auth with password and username
|
||||||
|
|
||||||
|
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.
|
||||||
|
```javascript
|
||||||
|
createCluster({
|
||||||
|
rootNodes: [{
|
||||||
|
url: 'redis://10.0.0.1:30001'
|
||||||
|
}, {
|
||||||
|
url: 'redis://10.0.0.2:30002'
|
||||||
|
}],
|
||||||
|
defaults: {
|
||||||
|
username: 'username',
|
||||||
|
password: 'password'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Node Address Map
|
## Node Address Map
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user