From 85bf97bb390a53d3f4aec846956479775243c263 Mon Sep 17 00:00:00 2001 From: "bodong.ybd" Date: Wed, 25 Jan 2023 06:52:15 +0800 Subject: [PATCH] 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 --- docs/clustering.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/clustering.md b/docs/clustering.md index 26acfa0a79..48fc98640c 100644 --- a/docs/clustering.md +++ b/docs/clustering.md @@ -40,6 +40,22 @@ const value = await cluster.get('key'); | modules | | Included [Redis Modules](../README.md#packages) | | scripts | | Script definitions (see [Lua Scripts](../README.md#lua-scripts)) | | 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