You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-21
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ createClient({
57
57
});
58
58
```
59
59
60
-
You can also use discrete parameters, UNIX sockets, and even TLS to connect. Details can be found in in the [Wiki](https://github.com/redis/node-redis/wiki/lib.socket#RedisSocketOptions).
60
+
You can also use discrete parameters, UNIX sockets, and even TLS to connect. Details can be found in the [client configuration guide](./docs/client-configuration.md).
Connecting to a cluster is a bit different. Create the client by specifying some (or all) of the nodes in your cluster and then use it like a non-clustered client:
232
+
There are two functions that disconnect a client from the Redis server. In most scenarios you should use `.quit()` to ensure that pending commands are sent to Redis before closing a connection.
233
233
234
-
```typescript
235
-
import { createCluster } from'redis';
234
+
#### `.QUIT()`/`.quit()`
236
235
237
-
(async () => {
238
-
const cluster =createCluster({
239
-
rootNodes: [
240
-
{
241
-
url: 'redis://10.0.0.1:30001'
242
-
},
243
-
{
244
-
url: 'redis://10.0.0.2:30002'
245
-
}
246
-
]
247
-
});
236
+
Gracefully close a client's connection to Redis, by sending the [`QUIT`](https://redis.io/commands/quit) command to the server. Before quitting, the client executes any remaining commands in its queue, and will receive replies from Redis for each of them.
Forcibly close a client's connection to Redis immediately. Calling `disconnect` will not send further pending commands to the Redis server, or wait for or parse outstanding responses.
252
255
253
-
awaitcluster.set('key', 'value');
254
-
const value =awaitcluster.get('key');
255
-
})();
256
+
```typescript
257
+
awaitclient.disconnect();
256
258
```
257
259
258
260
### Auto-Pipelining
@@ -273,6 +275,23 @@ await Promise.all([
273
275
]);
274
276
```
275
277
278
+
### Clustering
279
+
280
+
Check out the [Clustering Guide](./docs/clustering.md) when using Node Redis to connect to a Redis Cluster.
281
+
282
+
## Supported Redis versions
283
+
284
+
Node Redis is supported with the following versions of Redis:
285
+
286
+
| Version | Supported |
287
+
|---------|--------------------|
288
+
| 6.2.z |:heavy_check_mark:|
289
+
| 6.0.z |:heavy_check_mark:|
290
+
| 5.y.z |:heavy_check_mark:|
291
+
| < 5.0 |:x:|
292
+
293
+
> Node Redis should work with older versions of Redis, but it is not fully tested and we cannot offer support.
294
+
276
295
## Contributing
277
296
278
297
If you'd like to contribute, check out the [contributing guide](CONTRIBUTING.md).
Copy file name to clipboardExpand all lines: SECURITY.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,9 @@
5
5
Node Redis is generally backwards compatible with very few exceptions, so we recommend users to always use the latest version to experience stability, performance and security.
Connecting to a cluster is a bit different. Create the client by specifying some (or all) of the nodes in your cluster and then use it like a regular client instance:
| rootNodes || An array of root nodes that are part of the cluster, which will be used to get the cluster topology. Each element in the array is a client configuration object. There is no need to specify every node in the cluster, 3 should be enough to reliably connect and obtain the cluster configuration from the server |
38
+
| defaults || The default configuration values for every client in the cluster. Use this for example when specifying an ACL user to connect with |
39
+
| useReplicas |`false`| When `true`, distribute load by executing readonly commands (such as `GET`, `GEOSEARCH`, etc.) across all cluster nodes. When `false`, only use master nodes |
40
+
| maxCommandRedirections |`16`| The maximum number of times a command will be redirected due to `MOVED` or `ASK` errors ||
41
+
42
+
## Command Routing
43
+
44
+
### Commands that operate on Redis Keys
45
+
46
+
Commands such as `GET`, `SET`, etc. will be routed by the first key, for instance `MGET 1 2 3` will be routed by the key `1`.
Admin commands such as `MEMORY STATS`, `FLUSHALL`, etc. are not attached to the cluster, and should be executed on a specific node using `.getSlot()` or `.getAllMasters()`.
51
+
52
+
### "Forwarded Commands"
53
+
54
+
Some commands (e.g. `PUBLISH`) are forwarded to other cluster nodes by the Redis server. The client will send these commands to a random node in order to spread the load across the cluster.
0 commit comments