1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

a little bit docs

This commit is contained in:
Leibale
2023-11-09 21:01:26 -05:00
parent 37c39b71c9
commit 7247777a6f
8 changed files with 97 additions and 115 deletions

View File

@@ -4,26 +4,22 @@
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:
```typescript
```javascript
import { createCluster } from 'redis';
const cluster = createCluster({
rootNodes: [
{
const cluster = await createCluster({
rootNodes: [{
url: 'redis://10.0.0.1:30001'
},
{
}, {
url: 'redis://10.0.0.2:30002'
}
]
});
cluster.on('error', (err) => console.log('Redis Cluster Error', err));
await cluster.connect();
}]
})
.on('error', err => console.log('Redis Cluster Error', err))
.connect();
await cluster.set('key', 'value');
const value = await cluster.get('key');
await cluster.close();
```
## `createCluster` configuration