Skip to content

docs: added info on how to use flushAll with createCluster #2447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/clustering.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ Commands such as `GET`, `SET`, etc. are routed by the first key, for instance `M

Admin commands such as `MEMORY STATS`, `FLUSHALL`, etc. are not attached to the cluster, and must be executed on a specific node via `.getSlotMaster()`.

Here is an example of how to FLUSHALL until [#2431](https://github.com/redis/node-redis/issues/2431) will be implemented:
```javascript
await Promise.all(
cluster.masters.map(async master => {
await (await cluster.nodeClient(master)).flushAll();
});
);
```

```javascript
cluster.slots - to get the client of a specific slot
cluster.shards - to work on a "per shard" (master + it's replicas) basis.
cluster.masters - just the masters
cluster.replicas - just the replicas
```


### "Forwarded Commands"

Certain commands (e.g. `PUBLISH`) are forwarded to other cluster nodes by the Redis server. This client sends these commands to a random node in order to spread the load across the cluster.